Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
3cfe1fa1
Commit
3cfe1fa1
authored
6 years ago
by
Tania Fecheta
Browse files
Options
Downloads
Patches
Plain Diff
fix(fragmentRecommendations): use findLast instead of two filters and cover the undefined case
parent
42345747
No related branches found
No related tags found
3 merge requests
!176
Sprint 24
,
!171
Sprint 24
,
!157
fix(fragmentRecommendation): allow HE to make another recommendation on the same…
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js
+17
-13
17 additions, 13 deletions
...cript-manager/src/routes/fragmentsRecommendations/post.js
with
17 additions
and
13 deletions
packages/component-manuscript-manager/src/routes/fragmentsRecommendations/post.js
+
17
−
13
View file @
3cfe1fa1
const
uuid
=
require
(
'
uuid
'
)
const
uuid
=
require
(
'
uuid
'
)
const
{
pick
,
get
,
set
,
has
,
isEmpty
,
last
}
=
require
(
'
lodash
'
)
const
{
pick
,
get
,
set
,
has
,
isEmpty
,
last
,
findLast
}
=
require
(
'
lodash
'
)
const
config
=
require
(
'
config
'
)
const
config
=
require
(
'
config
'
)
const
{
v4
}
=
require
(
'
uuid
'
)
const
{
v4
}
=
require
(
'
uuid
'
)
const
logger
=
require
(
'
@pubsweet/logger
'
)
const
logger
=
require
(
'
@pubsweet/logger
'
)
...
@@ -41,11 +41,14 @@ module.exports = models => async (req, res) => {
...
@@ -41,11 +41,14 @@ module.exports = models => async (req, res) => {
})
})
}
}
const
currentUserRecommendation
=
get
(
fragment
,
'
recommendations
'
,
[]).
filter
(
const
currentUserRecommendations
=
get
(
r
=>
r
.
userId
===
req
.
user
,
fragment
,
)
'
recommendations
'
,
[],
).
filter
(
r
=>
r
.
userId
===
req
.
user
)
const
returnToHERecommendations
=
get
(
fragment
,
'
recommendations
'
,
[]).
filter
(
const
returnToHERecommendation
=
findLast
(
get
(
fragment
,
'
recommendations
'
,
[]),
r
=>
r
.
recommendation
===
'
return-to-handling-editor
'
,
r
=>
r
.
recommendation
===
'
return-to-handling-editor
'
,
)
)
const
authsome
=
authsomeHelper
.
getAuthsome
(
models
)
const
authsome
=
authsomeHelper
.
getAuthsome
(
models
)
...
@@ -80,21 +83,22 @@ module.exports = models => async (req, res) => {
...
@@ -80,21 +83,22 @@ module.exports = models => async (req, res) => {
if
(
if
(
last
(
collection
.
fragments
)
===
fragmentId
&&
last
(
collection
.
fragments
)
===
fragmentId
&&
!
isEmpty
(
currentUserRecommendation
)
!
isEmpty
(
currentUserRecommendation
s
)
)
{
)
{
if
(
recommendationType
===
recommendations
.
type
.
review
)
{
if
(
recommendationType
===
recommendations
.
type
.
review
)
{
return
res
return
res
.
status
(
400
)
.
status
(
400
)
.
json
({
error
:
'
Cannot write another review on this version.
'
})
.
json
({
error
:
'
Cannot write another review on this version.
'
})
}
}
else
if
(
if
(
recommendationType
===
recommendations
.
type
.
editor
&&
recommendationType
===
recommendations
.
type
.
editor
&&
last
(
returnToHERecommendations
).
createdOn
<
((
returnToHERecommendation
&&
last
(
currentUserRecommendation
).
createdOn
returnToHERecommendation
.
createdOn
<=
last
(
currentUserRecommendations
).
createdOn
)
||
!
returnToHERecommendation
)
)
{
)
{
return
res
return
res
.
status
(
400
).
json
({
.
status
(
400
)
error
:
'
Cannot make another recommendation on this version.
'
,
.
json
({
error
:
'
Cannot make another recommendation on this version.
'
})
})
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment