Skip to content
Snippets Groups Projects
Commit 85ab8d3e authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

feat(submitRevision): handle errors when collapsing the contextual boxes

parent 9314f70a
No related branches found
No related tags found
3 merge requests!108Hin 858 revision fix,!106Hin 858,!97HIN-858
......@@ -31,7 +31,6 @@ const ResponseToReviewer = ({
}) => (
<ContextualBox
label="Response to Reviewer Comments"
mt={1}
startExpanded
transparent
>
......
......@@ -84,4 +84,6 @@ const Root = styled.div`
padding: calc(${th('gridUnit')} * 2);
`
export default reduxForm({ form: 'revision' })(SubmitRevision)
export default reduxForm({ form: 'revision', destroyOnUnmount: false })(
SubmitRevision,
)
import { actions } from 'pubsweet-client'
import { get, debounce, omit, set } from 'lodash'
import { handleError } from 'pubsweet-component-faraday-ui'
import { get, debounce, omit, mergeWith, set } from 'lodash'
import { autosaveRequest } from 'pubsweet-component-wizard/src/redux/autosave'
import { submitRevision } from 'pubsweet-component-wizard/src/redux/conversion'
......@@ -11,12 +11,6 @@ const parseRevision = (values, fragment) => {
...fragment,
revision: {
...v,
metadata: mergeWith(
{},
fragment.metadata,
v.metadata,
(obj, src) => (src === '' ? obj : src),
),
},
}
}
......@@ -31,8 +25,10 @@ export const onChange = debounce(_onChange, 1000, { maxWait: 5000 })
export const onSubmit = (
values,
dispatch,
{ history, fragment, collection, showModal, setFetching },
{ history, fragment, collection, showModal, setFetching, canSubmit },
) => {
if (!canSubmit) return
showModal({
title: 'Ready to submit your revision?',
subtitle: `Once submitted, the submission can't be modified.`,
......
......@@ -9,8 +9,8 @@ import {
withFileDownload,
} from 'pubsweet-component-faraday-ui'
import { DragDropContext } from 'react-dnd'
import { change as changeForm } from 'redux-form'
import HTML5Backend from 'react-dnd-html5-backend'
import { change as changeForm, getFormSyncErrors, isPristine } from 'redux-form'
import { withModal } from 'pubsweet-component-modal/src/components'
import {
compose,
......@@ -39,8 +39,10 @@ export default compose(
withFileDownload,
connect(
state => ({
isPristine: isPristine('revision')(state),
formErrors: getFormSyncErrors('revision')(state),
canSubmit: !get(state, 'form.revision.syncErrors'),
hasFormError:
get(state, 'form.revision.syncErrors') &&
get(state, 'form.revision.anyTouched', false),
}),
{ changeForm },
),
......@@ -102,6 +104,7 @@ export default compose(
'journal',
'history',
'fragment',
'canSubmit',
'addAuthor',
'showModal',
'changeForm',
......@@ -114,6 +117,7 @@ export default compose(
'downloadFile',
'deleteAuthor',
'getSignedUrl',
'hasFormError',
'fetchingError',
'addResponseFile',
'deleteResponseFile',
......@@ -121,7 +125,6 @@ export default compose(
onChange,
onSubmit,
validate,
hasFormError: !props.isPristine && !!props.formErrors,
responseFile: get(
props,
'formValues.revision.responseToReviewers.file',
......
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