Commit 5bfe0054 authored by Yannis Barlas's avatar Yannis Barlas

feat(submission form): re-open form for revisions

parent cfc77e17
......@@ -12,6 +12,7 @@ import {
isDatatypeSelected,
isFullSubmissionReady,
isInitialSubmissionReady,
isUnderRevision,
} from '../helpers/status'
import { ArticlePreviewModal } from './ui'
......@@ -94,6 +95,7 @@ const SubmissionForm = props => {
const initialSubmissionState = !initial
const dataTypeSelectionState = initial && !datatypeSelected
const fullSubmissionState = initial && datatypeSelected && !full
const revisionState = isUnderRevision(status)
return (
<React.Fragment>
......@@ -103,7 +105,7 @@ const SubmissionForm = props => {
<DatatypeSelect article={article} values={values} {...props} />
)}
{fullSubmissionState &&
{(fullSubmissionState || revisionState) &&
values.dataType === 'geneExpression' && (
<Authorize object={article} operation="isAuthor" unauthorized={null}>
<GeneExpressionForm readOnly={readOnly} {...props} />
......@@ -123,7 +125,7 @@ const SubmissionForm = props => {
)}
</Toggle>
{(initialSubmissionState || fullSubmissionState) &&
{(initialSubmissionState || fullSubmissionState || revisionState) &&
isValid && (
<Toggle intial={false}>
{({ on, toggle }) => (
......
......@@ -14,7 +14,11 @@ import SubmitForm from './form/SubmissionForm'
import Loading from './Loading'
import SubmissionForm from './SubmissionForm'
import { ArticlePreview } from './ui'
import { isEditableByAuthor, isFullSubmissionReady } from '../helpers/status'
import {
isEditableByAuthor,
isFullSubmissionReady,
isUnderRevision,
} from '../helpers/status'
import { SubmissionSuccessModal } from '../ui'
const SplitScreen = styled.div`
......@@ -44,19 +48,21 @@ const Form = props => {
const { article, showModal, update, upload } = props
return (
<SubmitForm
article={article}
showModal={showModal}
update={update}
upload={upload}
>
{formProps => (
<div>
<h1>Submit your article</h1>
<SubmissionForm article={article} {...formProps} />
</div>
)}
</SubmitForm>
<Authorize object={article} operation="isAuthor">
<SubmitForm
article={article}
showModal={showModal}
update={update}
upload={upload}
>
{formProps => (
<div>
<h1>Submit your article</h1>
<SubmissionForm article={article} {...formProps} />
</div>
)}
</SubmitForm>
</Authorize>
)
}
......@@ -67,6 +73,7 @@ const Submit = props => {
const { status } = article
const full = isFullSubmissionReady(status)
const editableByAuthor = isEditableByAuthor(status)
const underRevision = isUnderRevision(status)
/*
if not full:
......@@ -105,7 +112,7 @@ const Submit = props => {
let display = null
if (!full) {
if (!full || (full && underRevision)) {
if (editableByAuthor) {
display = (
<Authorize
......@@ -129,7 +136,7 @@ const Submit = props => {
}
}
if (full) {
if (full && !underRevision) {
display = (
<Authorize
object={article}
......
......@@ -124,7 +124,8 @@ const isDatatypeSelected = status => {
const isEditableByAuthor = status =>
isInitialSubmissionReady(status) === false ||
(isDatatypeSelected(status) && isFullSubmissionReady(status) === false)
(isDatatypeSelected(status) && isFullSubmissionReady(status) === false) ||
isUnderRevision(status)
/*
DECISION
......@@ -169,6 +170,8 @@ const getDecision = status => {
return truthy[0]
}
const isUnderRevision = status => getDecision(status) === 'revise'
/*
SCIENCE OFFICER APPROVAL
*/
......@@ -219,6 +222,7 @@ const updateSubmissionStatus = (status, newDatatype) => {
const initial = isInitialSubmissionReady(newStatus)
const datatype = isDatatypeSelected(newStatus)
const full = isFullSubmissionReady(newStatus)
const underRevision = isUnderRevision(newStatus)
if (!initial) return setInitialSubmissionReady(newStatus)
if (initial && !datatype) {
......@@ -229,6 +233,11 @@ const updateSubmissionStatus = (status, newDatatype) => {
}
if (datatype && !full) return setFullSubmissionReady(newStatus)
if (full && underRevision) {
newStatus.decision = cleanDecision
return newStatus
}
throw new Error(
'Cannot update submission status, as it has been fully submitted already',
)
......@@ -256,6 +265,7 @@ export {
isReviewerInvited,
isReviewerSubmitted,
isRevise,
isUnderRevision,
setApproved,
setAccepted,
setDatatypeSelected,
......
......@@ -15,12 +15,22 @@ const cleanReviewStatus = {
submitted: false,
}
const cleanScienceOfficerStatus = {
approved: null,
pending: false,
}
const isMember = (team, userId) => team && team.members.includes(userId)
const isUserInGlobalTeams = (globalTeams, user) =>
user.admin || globalTeams.some(team => isMember(team, user.id))
// END TO DO
const runRevisionActions = async manuscriptId => {
const manuscript = await Manuscript.query().findById(manuscriptId)
const status = clone(manuscript.status)
status.scienceOfficer = cleanScienceOfficerStatus
await manuscript.$query().patch({ status })
}
const manuscriptMetadataUpdate = async (_, { data, manuscriptId }, ctx) => {
const { doi } = data
......@@ -150,11 +160,21 @@ const resolvers = {
} else if (update.status.decision.rejected) {
notify('articleRejected', notifyContext)
} else if (update.status.decision.revise) {
runRevisionActions(data.id)
notify('articleRevision', notifyContext)
} else {
/*
Decision status went from defined to not defined.
An under revision manuscript has been resubmitted.
Reset the decision text as well.
*/
await Manuscript.query()
.patch({ decisionLetter: null })
.where({ id: data.id })
}
}
// return update
return updated
},
},
......
......@@ -158,7 +158,14 @@ const resolvers = {
status = 'pendingDecision'
}
reviewer.push({ ...article, reviewerStatus: status })
// If article is under revision, do not show it
let showArticle = false
const isUnderRevision = article.status.decision.revise
if (!isUnderRevision) showArticle = true
if (showArticle) {
reviewer.push({ ...article, reviewerStatus: status })
}
}
})
return reviewer
......
Markdown is supported
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