Skip to content
Snippets Groups Projects
Commit 671f6a3a authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

feat(component-manuscript-manager): update status after EiC reject

parent 6a8fd320
No related branches found
No related tags found
1 merge request!10Sprint #12
...@@ -59,6 +59,14 @@ module.exports = { ...@@ -59,6 +59,14 @@ module.exports = {
public: 'Under Review', public: 'Under Review',
private: 'Pending Approval', private: 'Pending Approval',
}, },
rejected: {
public: 'Rejected',
private: 'Rejected',
},
published: {
public: 'Published',
private: 'Published',
},
}, },
'manuscript-types': { 'manuscript-types': {
research: 'Research', research: 'Research',
......
...@@ -15,7 +15,7 @@ const FragmentsRecommendations = app => { ...@@ -15,7 +15,7 @@ const FragmentsRecommendations = app => {
* @apiParam {fragmentId} fragmentId Fragment id * @apiParam {fragmentId} fragmentId Fragment id
* @apiParamExample {json} Body * @apiParamExample {json} Body
* { * {
* "recommendation": "accept", [acceptedValues: accept, revise, etc.], * "recommendation": "publish", [acceptedValues: publish, reject, minor, major],
* "comments": * "comments":
* [ * [
* { * {
...@@ -40,7 +40,7 @@ const FragmentsRecommendations = app => { ...@@ -40,7 +40,7 @@ const FragmentsRecommendations = app => {
* "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6", * "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
* "createdOn": 1525428890167, * "createdOn": 1525428890167,
* "updatedOn": 1525428890167, * "updatedOn": 1525428890167,
* "recommendation": "accept", [acceptedValues: accept, revise, etc.], * "recommendation": "publish",
* "comments": * "comments":
* [ * [
* { * {
...@@ -56,7 +56,7 @@ const FragmentsRecommendations = app => { ...@@ -56,7 +56,7 @@ const FragmentsRecommendations = app => {
* ] * ]
* } * }
* ], * ],
* "recommendationType": "review" [acceptedValues: review, editorRecommendation] * "recommendationType": "review"
* } * }
* @apiErrorExample {json} Invite user errors * @apiErrorExample {json} Invite user errors
* HTTP/1.1 403 Forbidden * HTTP/1.1 403 Forbidden
...@@ -70,14 +70,14 @@ const FragmentsRecommendations = app => { ...@@ -70,14 +70,14 @@ const FragmentsRecommendations = app => {
require(`${routePath}/post`)(app.locals.models), require(`${routePath}/post`)(app.locals.models),
) )
/** /**
* @api {patch} /api/collections/:collectionId/fragments/:fragmentId/recommendations/:recommendationId Create a recommendation on a fragment * @api {patch} /api/collections/:collectionId/fragments/:fragmentId/recommendations/:recommendationId Modify a recommendation on a fragment
* @apiGroup FragmentsRecommendations * @apiGroup FragmentsRecommendations
* @apiParam {collectionId} collectionId Collection id * @apiParam {collectionId} collectionId Collection id
* @apiParam {fragmentId} fragmentId Fragment id * @apiParam {fragmentId} fragmentId Fragment id
* @apiParam {recommendationId} recommendationId Recommendation id * @apiParam {recommendationId} recommendationId Recommendation id
* @apiParamExample {json} Body * @apiParamExample {json} Body
* { * {
* "recommendation": "accept", [acceptedValues: accept, revise, etc.], * "recommendation": "publish", [acceptedValues: publish, reject, minor, major],
* "comments": * "comments":
* [ * [
* { * {
...@@ -102,7 +102,7 @@ const FragmentsRecommendations = app => { ...@@ -102,7 +102,7 @@ const FragmentsRecommendations = app => {
* "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6", * "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
* "createdOn": 1525428890167, * "createdOn": 1525428890167,
* "updatedOn": 1525428890167, * "updatedOn": 1525428890167,
* "recommendation": "accept", [acceptedValues: accept, revise, etc.], * "recommendation": "publish",
* "comments": * "comments":
* [ * [
* { * {
......
...@@ -12,6 +12,29 @@ const updateStatusByRecommendation = async (collection, recommendation) => { ...@@ -12,6 +12,29 @@ const updateStatusByRecommendation = async (collection, recommendation) => {
await collection.save() await collection.save()
} }
const updateFinalStatusByRecommendation = async (
collection,
recommendation,
) => {
let newStatus
switch (recommendation) {
case 'reject':
newStatus = 'rejected'
break
case 'publish':
newStatus = 'published'
break
case 'return-to-handling-editor':
newStatus = 'reviewCompleted'
break
default:
break
}
collection.status = newStatus
collection.visibleStatus = statuses[collection.status].private
await collection.save()
}
const updateStatus = async (collection, newStatus) => { const updateStatus = async (collection, newStatus) => {
collection.status = newStatus collection.status = newStatus
collection.visibleStatus = statuses[collection.status].private collection.visibleStatus = statuses[collection.status].private
...@@ -55,4 +78,5 @@ module.exports = { ...@@ -55,4 +78,5 @@ module.exports = {
getFragmentAndAuthorData, getFragmentAndAuthorData,
getAgreedReviewerInvitation, getAgreedReviewerInvitation,
updateStatus, updateStatus,
updateFinalStatusByRecommendation,
} }
...@@ -54,6 +54,12 @@ module.exports = models => async (req, res) => { ...@@ -54,6 +54,12 @@ module.exports = models => async (req, res) => {
newRecommendation.comments = comments || undefined newRecommendation.comments = comments || undefined
if (recommendationType === 'editorRecommendation') { if (recommendationType === 'editorRecommendation') {
if (reqUser.editorInChief === true) {
await collectionHelper.updateFinalStatusByRecommendation(
collection,
recommendation,
)
}
await collectionHelper.updateStatusByRecommendation( await collectionHelper.updateStatusByRecommendation(
collection, collection,
recommendation, recommendation,
......
...@@ -14,6 +14,11 @@ async function teamPermissions(user, operation, object, context) { ...@@ -14,6 +14,11 @@ async function teamPermissions(user, operation, object, context) {
let collectionsPermissions = await Promise.all( let collectionsPermissions = await Promise.all(
teams.map(async team => { teams.map(async team => {
const collection = await context.models.Collection.find(team.object.id) const collection = await context.models.Collection.find(team.object.id)
if (
collection.status === 'rejected' &&
team.teamType.permissions === 'reviewer'
)
return null
const collPerm = { const collPerm = {
id: collection.id, id: collection.id,
permission: team.teamType.permissions, permission: team.teamType.permissions,
......
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