Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digibib
deichman
Commits
42a69ae7
Commit
42a69ae7
authored
Feb 19, 2021
by
Magnus Westergaard
Browse files
DEICH-5555
: If previewing a recommendation draft, hide all other recommendations.
parent
fda201f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
deichman.no/server/routes/resources.js
View file @
42a69ae7
...
...
@@ -581,19 +581,26 @@ const filterAndSortRecommendations = (
showDraftRecommendationById
=
null
)
=>
{
const
allRecommendations
=
pubRecommendations
.
concat
(
workRecommendations
);
const
uniqueR
ecommendations
=
new
Map
();
const
r
ecommendations
ById
=
new
Map
();
allRecommendations
.
forEach
(
recommendation
=>
{
console
.
log
(
recommendation
.
created
);
uniqueRecommendations
.
set
(
recommendation
.
id
,
recommendation
);
recommendationsById
.
set
(
recommendation
.
id
,
recommendation
);
});
const
filteredRecommendations
=
Array
.
from
(
uniqueRecommendations
.
values
())
const
uniqueRecommendations
=
Array
.
from
(
recommendationsById
.
values
());
if
(
showDraftRecommendationById
)
{
return
uniqueRecommendations
.
filter
(
rec
=>
rec
.
id
===
`https://content.deichman.no/recommendation/
${
showDraftRecommendationById
}
`
);
}
const
filteredRecommendations
=
uniqueRecommendations
.
filter
(
recommendation
=>
{
if
(
(
recommendation
.
onlyTargetPublication
&&
recommendation
.
target
.
id
!==
publicationUri
)
||
(
recommendation
.
status
===
"
draft
"
&&
recommendation
.
id
!==
`https://content.deichman.no/recommendation/
${
showDraftRecommendationById
}
`
)
recommendation
.
status
===
"
draft
"
)
{
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment