From a27ed04c443b0c499d27e7d57a2b0df89388d325 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Thu, 28 Nov 2024 17:57:55 +0600 Subject: [PATCH] pkp/pkp-lib#4787 reactive update of suggestion list in add reviewer modal --- .../users/SelectReviewerListPanel.vue | 38 +++++++++++++++++++ .../SelectReviewerSuggestionListItem.vue | 5 +-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/components/ListPanel/users/SelectReviewerListPanel.vue b/src/components/ListPanel/users/SelectReviewerListPanel.vue index 4d7fab2ee..84542560b 100644 --- a/src/components/ListPanel/users/SelectReviewerListPanel.vue +++ b/src/components/ListPanel/users/SelectReviewerListPanel.vue @@ -27,12 +27,14 @@ @@ -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)` */ @@ -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; + }, + }); + }, }, }; diff --git a/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue b/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue index 114bb9cf8..8dd96e838 100644 --- a/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue +++ b/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue @@ -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), ); }, },