Skip to content
Snippets Groups Projects
Commit 51b1462e authored by Anca Ursachi's avatar Anca Ursachi
Browse files

Merge branch 'HIN-1220' into 'develop'

fix(HERecommendation): Message for Author box should be mandatory when selecting…

See merge request !203
parents 9ef67461 296c248d
No related branches found
No related tags found
3 merge requests!222Sprint #26,!217Sprint #26,!203fix(HERecommendation): Message for Author box should be mandatory when selecting…
......@@ -79,6 +79,10 @@ const HERecommendation = ({
handleSubmit,
formValues,
highlight,
rejectRecommendation,
publishRecommendation,
minorRevisionRecommendation,
majorRevisionRecommendation,
...rest
}) => (
<ContextualBox
......@@ -111,31 +115,38 @@ const HERecommendation = ({
/>
</ItemOverrideAlert>
</Row>
{get(formValues, 'recommendation') === 'minor' ||
get(formValues, 'recommendation') === 'major' ? (
{(minorRevisionRecommendation || majorRevisionRecommendation) && (
<Row mt={2}>
<ResponsiveItem
data-test-id="editorial-recommendation-message-for-author"
mr={1}
vertical
>
<Label>
Message for Author <Text secondary>Optional</Text>
</Label>
<ValidatedField component={Textarea} name="public" />
<Label required>Message for Author</Label>
<ValidatedField
component={Textarea}
name="public"
validate={[required]}
/>
</ResponsiveItem>
</Row>
) : (
)}
{(publishRecommendation || rejectRecommendation) && (
<ResponsiveRow mt={2}>
<ResponsiveItem
data-test-id="editorial-recommendation-message-for-author"
mr={1}
vertical
>
<Label>
Message for Author <Text secondary>Optional</Text>
<Label required={!!rejectRecommendation}>
Message for Author{' '}
{publishRecommendation ? <Text secondary> Optional</Text> : ''}
</Label>
<ValidatedField component={Textarea} name="public" />
<ValidatedField
component={Textarea}
name="public"
validate={rejectRecommendation ? [required] : false}
/>
</ResponsiveItem>
<ResponsiveItem
......@@ -199,9 +210,14 @@ export default compose(
confirmMessage: options.find(
o => o.value === get(formValues, 'recommendation', 'publish'),
).button,
rejectRecommendation: get(formValues, 'recommendation') === 'reject',
publishRecommendation: get(formValues, 'recommendation') === 'publish',
minorRevisionRecommendation: get(formValues, 'recommendation') === 'minor',
majorRevisionRecommendation: get(formValues, 'recommendation') === 'major',
})),
reduxForm({
form: 'HERecommendation',
destroyOnUnmount: false,
onSubmit: (
values,
dispatch,
......
import React from 'react'
import { get, initial } from 'lodash'
import { get, initial, chain } from 'lodash'
import { compose, withProps } from 'recompose'
import styled from 'styled-components'
import { reduxForm } from 'redux-form'
......@@ -57,11 +57,12 @@ const ManuscriptEicDecision = ({
options,
decision,
formValues,
collection,
isFetching,
handleSubmit,
messagesLabel,
collection,
submitDecision,
lastHeRecommendation,
...rest
}) => (
<ContextualBox
......@@ -81,7 +82,8 @@ const ManuscriptEicDecision = ({
</ItemOverrideAlert>
</Row>
{decision !== 'publish' && (
{(decision === 'revision' ||
decision === 'return-to-handling-editor') && (
<Row mt={2} pl={1} pr={1}>
<Item vertical>
<Label required={decision !== 'reject'}>
......@@ -95,6 +97,22 @@ const ManuscriptEicDecision = ({
</Item>
</Row>
)}
{decision === 'reject' && (
<Row mt={2} pl={1} pr={1}>
<Item vertical>
<Label required={lastHeRecommendation !== 'reject'}>
{messagesLabel[get(formValues, 'decision', 'reject')]}
</Label>
<ValidatedField
component={ValidatedTextArea}
name="message"
validate={
lastHeRecommendation !== 'reject' ? [required] : undefined
}
/>
</Item>
</Row>
)}
<Row justify="flex-end" mt={1} pr={1}>
<Button onClick={handleSubmit} primary size="medium">
......@@ -112,7 +130,7 @@ export default compose(
modalKey: 'eic-decision',
modalComponent: MultiAction,
})),
withProps(({ formValues, collection }) => ({
withProps(({ formValues, collection, fragment }) => ({
modalTitle: eicDecisions.find(
o => o.value === get(formValues, 'decision', 'publish'),
).modalTitle,
......@@ -124,9 +142,15 @@ export default compose(
eicDecisions,
get(collection, 'status', 'submitted'),
),
lastHeRecommendation: chain(fragment)
.get('recommendations', [])
.last()
.get('recommendation', '')
.value(),
})),
reduxForm({
form: 'eic-decision',
destroyOnUnmount: false,
onSubmit: (
values,
dispatch,
......
......@@ -284,6 +284,7 @@ const ManuscriptLayout = ({
collection={collection}
expanded={eicDecisionExpanded}
formValues={get(formValues, 'eicDecision')}
fragment={fragment}
highlight={editorialRecommendations.length > 0}
messagesLabel={messagesLabel}
mt={2}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment