Commit f9c81784 authored by Giannis Kopanas's avatar Giannis Kopanas

Merge branch 'fix-colabra-submit' into 'master'

fix submit form

See merge request xpub/xpub!252
parents 2d5deb4d 8c7caffd
Pipeline #11053 passed with stages
in 6 minutes and 30 seconds
This diff is collapsed.
......@@ -517,6 +517,14 @@ class XpubCollabraMode {
return false
}
async isAllowedToReview(object) {
this.user = await this.context.models.User.find(this.userId)
const permission = await this.isAssignedReviewerEditor({
id: object.manuscriptId,
})
return permission
}
async canViewMySubmissionSection() {
this.user = await this.context.models.User.find(this.userId)
const manuscripts = await Promise.all(
......@@ -676,10 +684,14 @@ module.exports = {
return user.admin
},
create: (userId, operation, object, context) => true,
update: (userId, operation, object, context) => {
update: async (userId, operation, object, context) => {
const mode = new XpubCollabraMode(userId, operation, object, context)
if (mode.object === 'Manuscript' || mode.object === 'Team') {
if (
mode.object === 'Manuscript' ||
mode.object === 'Review' ||
mode.object === 'Team'
) {
return true
}
......@@ -687,6 +699,10 @@ module.exports = {
return true
}
if (mode.object.current.type === 'Review') {
return mode.isAllowedToReview(mode.object.current)
}
if (mode.object.current.type === 'Manuscript') {
return mode.canUpdateManuscript()
}
......@@ -736,13 +752,17 @@ module.exports = {
return mode.canViewPage()
},
'can view only admin': () => false,
read: (userId, operation, object, context) => {
read: async (userId, operation, object, context) => {
const mode = new XpubCollabraMode(userId, operation, object, context)
if (object === 'Manuscript') {
if (object === 'Manuscript' || object === 'Review') {
return true
}
if (object.type === 'Review') {
return mode.isAllowedToReview(object)
}
if (object.type === 'Manuscript') {
return mode.canReadManuscript()
}
......
......@@ -5,15 +5,20 @@ const resolvers = {
Mutation: {
async updateReview(_, { id, input }, ctx) {
if (id) {
const review = await Review.find(id)
const review = await ctx.connectors.Review.fetchOne(id, ctx)
const update = merge({}, review, input)
const updateReview = await new Review(update).save()
updateReview.comments = await updateReview.getComments()
return updateReview
await ctx.connectors.Review.update(id, update, ctx)
// Load Review
const rvw = await new Review(update)
rvw.comments = await rvw.getComments()
return rvw
}
input.userId = ctx.user
const review = await new Review(input).save()
const review = await new Review(input)
await review.save()
review.comments = await review.getComments()
return review
},
},
......
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