From e8f973dea78497b5e74d3a0964dde956584cdbef Mon Sep 17 00:00:00 2001 From: Sebastian Mihalache <sebastian.mihalache@gmail.con> Date: Fri, 3 Aug 2018 11:44:23 +0300 Subject: [PATCH] fix(manuscripts and revisions): fix statuses updates --- .../fragments/notifications/notifications.js | 1 + .../notifications/notifications.js | 6 +++--- .../routes/fragmentsRecommendations/post.js | 21 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js index b2d0f8e26..012113ffd 100644 --- a/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js @@ -68,6 +68,7 @@ module.exports = { email, baseUrl, titleText, + UserModel, fragmentHelper, subjectBaseText, }) diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js index ef6033c77..f99bbd3b5 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js @@ -340,13 +340,13 @@ const sendEiCEmail = ({ eicName, eicEmail, titleText, - recommendation, + recommendation: { recommendation, comments: recComments = [] }, subjectBaseText, }) => { let emailType email.content.subject = `${subjectBaseText} Recommendation` - switch (recommendation.recommendation) { + switch (recommendation) { case 'minor': case 'major': emailType = 'eic-request-revision-from-he' @@ -366,7 +366,7 @@ const sendEiCEmail = ({ name: eicName, } - const privateNote = recommendation.comments.find(comm => comm.private) + const privateNote = recComments.find(comm => comm.private) const content = get(privateNote, 'content') const comments = content ? `Note to Editor: "${content}"` : '' const { html, text } = email.getBody({ diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js index 61b5cc07c..376779842 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js @@ -58,17 +58,18 @@ module.exports = models => async (req, res) => { newRecommendation.recommendation = recommendation || undefined newRecommendation.comments = comments || undefined - const collectionHelper = new Collection({ collection }) - collectionHelper.updateStatusOnRecommendation({ - isEditorInChief, - recommendation, - }) - - if (!isEditorInChief && ['minor', 'major'].includes(recommendation)) { - fragment.revision = pick(fragment, ['authors', 'files', 'metadata']) - } - if (recommendationType === 'editorRecommendation') { + const collectionHelper = new Collection({ collection }) + + collectionHelper.updateStatusOnRecommendation({ + isEditorInChief, + recommendation, + }) + + if (!isEditorInChief && ['minor', 'major'].includes(recommendation)) { + fragment.revision = pick(fragment, ['authors', 'files', 'metadata']) + } + notifications.sendNotifications({ fragment, collection, -- GitLab