diff --git a/packages/component-manuscript-manager/src/helpers/Collection.js b/packages/component-manuscript-manager/src/helpers/Collection.js new file mode 100644 index 0000000000000000000000000000000000000000..4949969b040748ff54163782eda0155acd6ec789 --- /dev/null +++ b/packages/component-manuscript-manager/src/helpers/Collection.js @@ -0,0 +1,13 @@ +const config = require('config') + +const statuses = config.get('statuses') + +const updateStatus = async (collection, newStatus) => { + collection.status = newStatus + collection.visibleStatus = statuses[collection.status].private + await collection.save() +} + +module.exports = { + updateStatus, +} diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/patch.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/patch.js index 5bf453ec9de7e3e2f5e6a494edc604a8a093b48d..9c1b974768e0c4e9a009cce1f858dc9f1ea02864 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/patch.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/patch.js @@ -1,5 +1,6 @@ const helpers = require('../../helpers/helpers') const authsomeHelper = require('../../helpers/authsome') +const collectionHelper = require('../../helpers/Collection') module.exports = models => async (req, res) => { const { collectionId, fragmentId, recommendationId } = req.params @@ -32,6 +33,8 @@ module.exports = models => async (req, res) => { }) Object.assign(recommendation, req.body) recommendation.updatedOn = Date.now() + if (req.body.submittedOn !== undefined) + await collectionHelper.updateStatus(collection, 'reviewCompleted') await fragment.save() return res.status(200).json(recommendation) } catch (e) { diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index a773b41f2bd0746604c0ca261d1b0aa01fe5267d..4edb74bf17a47ed1c72ed63d7420dbe2276aed9f 100644 --- a/packages/xpub-faraday/config/default.js +++ b/packages/xpub-faraday/config/default.js @@ -114,5 +114,9 @@ module.exports = { public: 'Under Review', private: 'Under Review', }, + reviewCompleted: { + public: 'Under Review', + private: 'Review Completed', + }, }, }