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

fix(submit-revision): fix bugs

parent c9aec53c
No related branches found
No related tags found
1 merge request!13Sprint #14
...@@ -74,7 +74,7 @@ module.exports = models => async (req, res) => { ...@@ -74,7 +74,7 @@ module.exports = models => async (req, res) => {
if (!['pendingApproval', 'revisionRequested'].includes(collection.status)) if (!['pendingApproval', 'revisionRequested'].includes(collection.status))
collectionHelper.updateStatus({ newStatus: 'reviewCompleted' }) collectionHelper.updateStatus({ newStatus: 'reviewCompleted' })
} }
await fragment.save()
return res.status(200).json(recommendation) return res.status(200).json(recommendation)
} catch (e) { } catch (e) {
const notFoundError = await services.handleNotFoundError(e, 'Item') const notFoundError = await services.handleNotFoundError(e, 'Item')
......
...@@ -7,8 +7,12 @@ import { Authors, Files } from './' ...@@ -7,8 +7,12 @@ import { Authors, Files } from './'
import { Expandable } from '../molecules/' import { Expandable } from '../molecules/'
const ManuscriptDetails = ({ const ManuscriptDetails = ({
collection: { authors = [] }, fragment: {
fragment: { conflicts = {}, files = {}, metadata: { abstract = '' } }, files = {},
authors = [],
conflicts = {},
metadata: { abstract = '' },
},
}) => ( }) => (
<Root> <Root>
<Expandable label="Details" startExpanded> <Expandable label="Details" startExpanded>
......
...@@ -53,7 +53,7 @@ const ManuscriptLayout = ({ ...@@ -53,7 +53,7 @@ const ManuscriptLayout = ({
project={project} project={project}
version={version} version={version}
/> />
<ManuscriptDetails collection={project} fragment={version} /> <ManuscriptDetails fragment={version} />
<ReviewsAndReports project={project} version={version} /> <ReviewsAndReports project={project} version={version} />
{canSeeEditorialComments && {canSeeEditorialComments &&
editorialRecommendations.length > 0 && ( editorialRecommendations.length > 0 && (
......
import moment from 'moment' import moment from 'moment'
import { get, find, capitalize, omit, isEmpty, isEqual, debounce } from 'lodash' import { get, find, capitalize, omit, isEmpty, debounce } from 'lodash'
import { actions } from 'pubsweet-client/src' import { actions } from 'pubsweet-client/src'
import { change as changeForm } from 'redux-form' import { change as changeForm } from 'redux-form'
...@@ -137,25 +137,23 @@ const onChange = ( ...@@ -137,25 +137,23 @@ const onChange = (
values, values,
dispatch, dispatch,
{ project, version, createRecommendation, updateRecommendation }, { project, version, createRecommendation, updateRecommendation },
previousValues,
) => { ) => {
const newValues = parseReviewRequest(values) const newValues = parseReviewRequest(values)
const prevValues = parseReviewRequest(previousValues) // if (!isEqual(newValues, prevValues)) {
if (!isEqual(newValues, prevValues)) { dispatch(autosaveRequest())
dispatch(autosaveRequest()) if (newValues.id) {
if (newValues.id) { updateRecommendation(project.id, version.id, newValues)
updateRecommendation(project.id, version.id, newValues) .then(r => dispatch(autosaveSuccess(get(r, 'updatedOn'))))
.then(r => dispatch(autosaveSuccess(get(r, 'updatedOn')))) .catch(e => dispatch(autosaveFailure(e)))
.catch(e => dispatch(autosaveFailure(e))) } else {
} else { createRecommendation(project.id, version.id, newValues)
createRecommendation(project.id, version.id, newValues) .then(r => {
.then(r => { dispatch(changeForm('reviewerReport', 'id', r.id))
dispatch(changeForm('reviewerReport', 'id', r.id)) return dispatch(autosaveSuccess(get(r, 'updatedOn')))
return dispatch(autosaveSuccess(get(r, 'updatedOn'))) })
}) .catch(e => dispatch(autosaveFailure(e)))
.catch(e => dispatch(autosaveFailure(e)))
}
} }
// }
} }
export const onReviewChange = debounce(onChange, 1000, { maxWait: 5000 }) export const onReviewChange = debounce(onChange, 1000, { maxWait: 5000 })
...@@ -183,7 +181,7 @@ export const onReviewSubmit = ( ...@@ -183,7 +181,7 @@ export const onReviewSubmit = (
updateRecommendation(project.id, version.id, newValues) updateRecommendation(project.id, version.id, newValues)
.then(r => dispatch(autosaveSuccess(get(r, 'updatedOn')))) .then(r => dispatch(autosaveSuccess(get(r, 'updatedOn'))))
.then(() => { .then(() => {
dispatch(actions.getFragments()) dispatch(actions.getFragments({ id: project.id }))
hideModal() hideModal()
}) })
}, },
......
...@@ -73,13 +73,19 @@ const submitFragmentRevision = ({ ...@@ -73,13 +73,19 @@ const submitFragmentRevision = ({
history, history,
redirectPath = '/', redirectPath = '/',
}) => { }) => {
submitRevision(project.id, version.id).then(() => { submitRevision(project.id, version.id)
history.push(redirectPath, { .then(() => {
project: project.id, history.push(redirectPath, {
customId: project.customId, project: project.id,
version: version.id, customId: project.customId,
version: version.id,
})
})
.catch(error => {
if (error.validationErrors) {
throw new SubmissionError()
}
}) })
})
} }
const onSubmit = ( const onSubmit = (
......
...@@ -143,7 +143,7 @@ const DashboardCard = ({ ...@@ -143,7 +143,7 @@ const DashboardCard = ({
project.status !== 'draft' && ( project.status !== 'draft' && (
<DetailsView> <DetailsView>
<Top> <Top>
<AuthorsWithTooltip authors={project.authors} /> <AuthorsWithTooltip authors={version.authors} />
</Top> </Top>
<Bottom> <Bottom>
<LeftDetails flex={4}> <LeftDetails flex={4}>
......
import React from 'react' import React, { Fragment } from 'react'
import { th } from '@pubsweet/ui' import { th } from '@pubsweet/ui'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { get, isEqual } from 'lodash' import { get, isEqual } from 'lodash'
...@@ -6,6 +6,7 @@ import { connect } from 'react-redux' ...@@ -6,6 +6,7 @@ import { connect } from 'react-redux'
import styled from 'styled-components' import styled from 'styled-components'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { change as changeForm } from 'redux-form' import { change as changeForm } from 'redux-form'
import { selectCurrentVersion } from 'xpub-selectors'
import { import {
compose, compose,
lifecycle, lifecycle,
...@@ -35,7 +36,7 @@ const Files = ({ ...@@ -35,7 +36,7 @@ const Files = ({
isRevisionFlow, isRevisionFlow,
dropSortableFile, dropSortableFile,
}) => ( }) => (
<div> <Fragment>
<Error show={error}> File error, please try again.</Error> <Error show={error}> File error, please try again.</Error>
<FileSection <FileSection
addFile={addFile('manuscripts')} addFile={addFile('manuscripts')}
...@@ -89,12 +90,11 @@ const Files = ({ ...@@ -89,12 +90,11 @@ const Files = ({
title="Response to reviewers" title="Response to reviewers"
/> />
)} )}
</div> </Fragment>
) )
export default compose( export default compose(
getContext({ getContext({
version: PropTypes.object,
project: PropTypes.object, project: PropTypes.object,
}), }),
withRouter, withRouter,
...@@ -102,6 +102,7 @@ export default compose( ...@@ -102,6 +102,7 @@ export default compose(
(state, { project, version }) => ({ (state, { project, version }) => ({
error: getFileError(state), error: getFileError(state),
isFetching: getRequestStatus(state), isFetching: getRequestStatus(state),
version: selectCurrentVersion(state, project),
isRevisionFlow: isRevisionFlow(state, project, version), isRevisionFlow: isRevisionFlow(state, project, version),
}), }),
{ {
......
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