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

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

fix(HERecommendation): Message for Author box should be mandatory when selecting Minor revision/Majo
parent 8354785a
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 = ({ ...@@ -79,6 +79,10 @@ const HERecommendation = ({
handleSubmit, handleSubmit,
formValues, formValues,
highlight, highlight,
rejectRecommendation,
publishRecommendation,
minorRevisionRecommendation,
majorRevisionRecommendation,
...rest ...rest
}) => ( }) => (
<ContextualBox <ContextualBox
...@@ -111,31 +115,38 @@ const HERecommendation = ({ ...@@ -111,31 +115,38 @@ const HERecommendation = ({
/> />
</ItemOverrideAlert> </ItemOverrideAlert>
</Row> </Row>
{get(formValues, 'recommendation') === 'minor' || {(minorRevisionRecommendation || majorRevisionRecommendation) && (
get(formValues, 'recommendation') === 'major' ? (
<Row mt={2}> <Row mt={2}>
<ResponsiveItem <ResponsiveItem
data-test-id="editorial-recommendation-message-for-author" data-test-id="editorial-recommendation-message-for-author"
mr={1} mr={1}
vertical vertical
> >
<Label> <Label required>Message for Author</Label>
Message for Author <Text secondary>Optional</Text> <ValidatedField
</Label> component={Textarea}
<ValidatedField component={Textarea} name="public" /> name="public"
validate={[required]}
/>
</ResponsiveItem> </ResponsiveItem>
</Row> </Row>
) : ( )}
{(publishRecommendation || rejectRecommendation) && (
<ResponsiveRow mt={2}> <ResponsiveRow mt={2}>
<ResponsiveItem <ResponsiveItem
data-test-id="editorial-recommendation-message-for-author" data-test-id="editorial-recommendation-message-for-author"
mr={1} mr={1}
vertical vertical
> >
<Label> <Label required={!!rejectRecommendation}>
Message for Author <Text secondary>Optional</Text> Message for Author{' '}
{publishRecommendation ? <Text secondary> Optional</Text> : ''}
</Label> </Label>
<ValidatedField component={Textarea} name="public" /> <ValidatedField
component={Textarea}
name="public"
validate={rejectRecommendation ? [required] : false}
/>
</ResponsiveItem> </ResponsiveItem>
<ResponsiveItem <ResponsiveItem
...@@ -199,9 +210,14 @@ export default compose( ...@@ -199,9 +210,14 @@ export default compose(
confirmMessage: options.find( confirmMessage: options.find(
o => o.value === get(formValues, 'recommendation', 'publish'), o => o.value === get(formValues, 'recommendation', 'publish'),
).button, ).button,
rejectRecommendation: get(formValues, 'recommendation') === 'reject',
publishRecommendation: get(formValues, 'recommendation') === 'publish',
minorRevisionRecommendation: get(formValues, 'recommendation') === 'minor',
majorRevisionRecommendation: get(formValues, 'recommendation') === 'major',
})), })),
reduxForm({ reduxForm({
form: 'HERecommendation', form: 'HERecommendation',
destroyOnUnmount: false,
onSubmit: ( onSubmit: (
values, values,
dispatch, dispatch,
......
import React from 'react' import React from 'react'
import { get, initial } from 'lodash' import { get, initial, chain } from 'lodash'
import { compose, withProps } from 'recompose' import { compose, withProps } from 'recompose'
import styled from 'styled-components' import styled from 'styled-components'
import { reduxForm } from 'redux-form' import { reduxForm } from 'redux-form'
...@@ -57,11 +57,12 @@ const ManuscriptEicDecision = ({ ...@@ -57,11 +57,12 @@ const ManuscriptEicDecision = ({
options, options,
decision, decision,
formValues, formValues,
collection,
isFetching, isFetching,
handleSubmit, handleSubmit,
messagesLabel, messagesLabel,
collection,
submitDecision, submitDecision,
lastHeRecommendation,
...rest ...rest
}) => ( }) => (
<ContextualBox <ContextualBox
...@@ -81,7 +82,8 @@ const ManuscriptEicDecision = ({ ...@@ -81,7 +82,8 @@ const ManuscriptEicDecision = ({
</ItemOverrideAlert> </ItemOverrideAlert>
</Row> </Row>
{decision !== 'publish' && ( {(decision === 'revision' ||
decision === 'return-to-handling-editor') && (
<Row mt={2} pl={1} pr={1}> <Row mt={2} pl={1} pr={1}>
<Item vertical> <Item vertical>
<Label required={decision !== 'reject'}> <Label required={decision !== 'reject'}>
...@@ -95,6 +97,22 @@ const ManuscriptEicDecision = ({ ...@@ -95,6 +97,22 @@ const ManuscriptEicDecision = ({
</Item> </Item>
</Row> </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}> <Row justify="flex-end" mt={1} pr={1}>
<Button onClick={handleSubmit} primary size="medium"> <Button onClick={handleSubmit} primary size="medium">
...@@ -112,7 +130,7 @@ export default compose( ...@@ -112,7 +130,7 @@ export default compose(
modalKey: 'eic-decision', modalKey: 'eic-decision',
modalComponent: MultiAction, modalComponent: MultiAction,
})), })),
withProps(({ formValues, collection }) => ({ withProps(({ formValues, collection, fragment }) => ({
modalTitle: eicDecisions.find( modalTitle: eicDecisions.find(
o => o.value === get(formValues, 'decision', 'publish'), o => o.value === get(formValues, 'decision', 'publish'),
).modalTitle, ).modalTitle,
...@@ -124,9 +142,15 @@ export default compose( ...@@ -124,9 +142,15 @@ export default compose(
eicDecisions, eicDecisions,
get(collection, 'status', 'submitted'), get(collection, 'status', 'submitted'),
), ),
lastHeRecommendation: chain(fragment)
.get('recommendations', [])
.last()
.get('recommendation', '')
.value(),
})), })),
reduxForm({ reduxForm({
form: 'eic-decision', form: 'eic-decision',
destroyOnUnmount: false,
onSubmit: ( onSubmit: (
values, values,
dispatch, dispatch,
......
...@@ -284,6 +284,7 @@ const ManuscriptLayout = ({ ...@@ -284,6 +284,7 @@ const ManuscriptLayout = ({
collection={collection} collection={collection}
expanded={eicDecisionExpanded} expanded={eicDecisionExpanded}
formValues={get(formValues, 'eicDecision')} formValues={get(formValues, 'eicDecision')}
fragment={fragment}
highlight={editorialRecommendations.length > 0} highlight={editorialRecommendations.length > 0}
messagesLabel={messagesLabel} messagesLabel={messagesLabel}
mt={2} 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