Skip to content

Commit

Permalink
pkp/pkp-lib#4787 reactive update of suggestion list in add reviewer m…
Browse files Browse the repository at this point in the history
…odal
  • Loading branch information
touhidurabir committed Nov 29, 2024
1 parent a266a3b commit a27ed04
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
38 changes: 38 additions & 0 deletions src/components/ListPanel/users/SelectReviewerListPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@

<template #item="{item}">
<SelectReviewerSuggestionListItem
v-if="!item.approvedAt"
:key="item.id"
:item="item"
:submission-id="getParams.submissionId"
:stage-id="getParams.reviewStage"
:review-round-id="getParams.reviewRoundId"
:select-reviewer-label="selectReviewerLabel"
@update:suggestions="updateReviewerSuggestionList"
/>
</template>
</ListPanel>
Expand Down Expand Up @@ -361,6 +363,11 @@ export default {
return [];
},
},
/** The API Url to obtain reviewer suggestion for this submission */
reviewerSuggestionsApiUrl: {
type: String,
required: false,
},
},
emits: [
/** Emitted when a prop should be changed. Payload: `(id, newProps)` */
Expand Down Expand Up @@ -456,6 +463,37 @@ export default {
itemsMax,
});
},
/**
* Update the list of reviewer suggestions list
*
* @param {Number} reviewerSuggestionId
*/
updateReviewerSuggestionList(reviewerSuggestionId) {
this.isLoading = true;
$.ajax({
url: this.reviewerSuggestionsApiUrl + '/' + reviewerSuggestionId,
type: 'GET',
context: this,
headers: {
'X-Csrf-Token': pkp.currentUser.csrfToken,
},
error: this.ajaxErrorCallback,
success(r) {
// TODO : may be some better appraoch than this ?
if (r.approvedAt) {
this.suggestions.forEach((reviewerSuggestion) => {
if (reviewerSuggestion.id == reviewerSuggestionId) {
reviewerSuggestion.approvedAt = r.approvedAt;
}
});
}
},
complete(r) {
this.isLoading = false;
},
});
},
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ export default {
},
});
openLegacyModal(
{title: t('editor.submission.addReviewer')},
function () {},
openLegacyModal({title: t('editor.submission.addReviewer')}, () =>
this.$emit('update:suggestions', this.item.id),
);
},
},
Expand Down

0 comments on commit a27ed04

Please sign in to comment.