From de574ac7891098897682d2194ab42777d937b11f Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Wed, 30 Oct 2024 18:24:32 +0600 Subject: [PATCH] pkp/pkp-lib#4787 reviewer adding from suggestion working --- .../users/SelectReviewerListPanel.vue | 10 +- .../SelectReviewerSuggestionListItem.vue | 51 +++++++---- .../ReviewerSuggestionManager.vue | 66 ++++++++++++++ .../reviewerSuggestionManagerStore.js | 91 +++++++++++++++++++ .../useReviewerSuggestionManagerActions.js | 50 ++++++++++ src/pages/workflow/WorkflowPageOJS.vue | 2 + .../useWorkflowConfig/useWorkflowConfigOJS.js | 1 + .../workflowConfigEditorialOJS.js | 19 +++- 8 files changed, 262 insertions(+), 28 deletions(-) create mode 100644 src/managers/ReviewerSuggestionManager/ReviewerSuggestionManager.vue create mode 100644 src/managers/ReviewerSuggestionManager/reviewerSuggestionManagerStore.js create mode 100644 src/managers/ReviewerSuggestionManager/useReviewerSuggestionManagerActions.js diff --git a/src/components/ListPanel/users/SelectReviewerListPanel.vue b/src/components/ListPanel/users/SelectReviewerListPanel.vue index 2bababa11..190d4e2dc 100644 --- a/src/components/ListPanel/users/SelectReviewerListPanel.vue +++ b/src/components/ListPanel/users/SelectReviewerListPanel.vue @@ -29,8 +29,10 @@ @@ -354,12 +356,6 @@ export default { return []; }, }, - suggestionAddApiUrl: { - type: String, - default() { - return ''; - }, - }, }, emits: [ /** Emitted when a prop should be changed. Payload: `(id, newProps)` */ diff --git a/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue b/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue index 2eeb7e398..704bdcbc2 100644 --- a/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue +++ b/src/components/ListPanel/users/SelectReviewerSuggestionListItem.vue @@ -3,6 +3,7 @@
+ {{ fullName }} {{ affiliation }} @@ -11,6 +12,7 @@
+ {{ suggestionReason }}
@@ -29,20 +31,15 @@ diff --git a/src/managers/ReviewerSuggestionManager/reviewerSuggestionManagerStore.js b/src/managers/ReviewerSuggestionManager/reviewerSuggestionManagerStore.js new file mode 100644 index 000000000..cb08f628d --- /dev/null +++ b/src/managers/ReviewerSuggestionManager/reviewerSuggestionManagerStore.js @@ -0,0 +1,91 @@ +import {defineComponentStore} from '@/utils/defineComponentStore'; + +import {ref, computed, watch} from 'vue'; + +import {useFetch} from '@/composables/useFetch'; +import {useUrl} from '@/composables/useUrl'; + +import {useLocalize} from '@/composables/useLocalize'; +import {useReviewerSuggestionManagerActions} from './useReviewerSuggestionManagerActions'; +import {useDataChanged} from '@/composables/useDataChanged'; + +export const useReviewerSuggestionManagerStore = defineComponentStore( + 'reviewerSuggestionManager', + (props) => { + const {localize} = useLocalize(); + + const submissionId = ref(props.submission.id); + + const relativeUrl = computed(() => { + return `submissions/${encodeURIComponent(submissionId.value)}/reviewers/suggestions?approved=false`; + }); + + const {apiUrl: reviewerSuggestionApiUrl} = useUrl(relativeUrl); + + const {data: reviewerSuggestions, fetch: fetchreviewerSuggestion} = + useFetch(reviewerSuggestionApiUrl); + + watch(relativeUrl, () => { + reviewerSuggestions.value = null; + fetchreviewerSuggestion(); + }); + + fetchreviewerSuggestion(); + + const {triggerDataChange} = useDataChanged(() => fetchreviewerSuggestion()); + + function triggerDataChangeCallback() { + triggerDataChange(); + } + + const reviewerSuggestionsList = computed(() => { + if (!reviewerSuggestions.value) { + return []; + } + + const list = []; + + reviewerSuggestions.value.items.forEach((reviewerSuggestion) => { + list.push({ + id: reviewerSuggestion.id, + fullName: localize(reviewerSuggestion.fullName), + affiliation: localize(reviewerSuggestion.affiliation), + suggestionReason: localize(reviewerSuggestion.suggestionReason), + }); + }); + + return list; + }); + + /** + * Handling actions + */ + + const _actionFns = useReviewerSuggestionManagerActions(); + + const itemActions = computed(() => _actionFns.getItemActions({})); + + function enrichActionArg(args) { + return { + submissionStageId: props.submissionStageId, + submission: props.submission, + reviewRoundId: props.reviewRoundId, + ...args, + }; + } + + function reviewerSuggestionApprove({reviewerSuggestion}) { + _actionFns.reviewerSuggestionApprove( + enrichActionArg({reviewerSuggestion}), + triggerDataChangeCallback, + ); + } + + return { + reviewerSuggestionsList, + _actionFns, + itemActions, + reviewerSuggestionApprove, + }; + }, +); diff --git a/src/managers/ReviewerSuggestionManager/useReviewerSuggestionManagerActions.js b/src/managers/ReviewerSuggestionManager/useReviewerSuggestionManagerActions.js new file mode 100644 index 000000000..ad11d7a9e --- /dev/null +++ b/src/managers/ReviewerSuggestionManager/useReviewerSuggestionManagerActions.js @@ -0,0 +1,50 @@ +import {useLegacyGridUrl} from '@/composables/useLegacyGridUrl'; +import {useLocalize} from '@/composables/useLocalize'; + +export const Actions = { + REVIEWER_SUGGESTION_APPROVE: 'reviewerSuggestionApprove', +}; + +export function useReviewerSuggestionManagerActions() { + const {t} = useLocalize(); + + function reviewerSuggestionApprove( + {submissionStageId, submission, reviewRoundId, reviewerSuggestion}, + finishedCallback, + ) { + const {openLegacyModal} = useLegacyGridUrl({ + component: 'grid.users.reviewer.ReviewerGridHandler', + op: 'showReviewerForm', + params: { + submissionId: submission.id, + stageId: submissionStageId, + reviewRoundId: reviewRoundId, + selectionType: pkp.const.REVIEWER_SELECT_CREATE, + reviewerSuggestionId: reviewerSuggestion.id, + }, + }); + + openLegacyModal( + {title: t('editor.submission.addReviewer')}, + finishedCallback, + ); + } + + function getItemActions() { + const {t} = useLocalize(); + const actions = []; + + actions.push({ + label: t('editor.submission.addReviewer'), + name: Actions.REVIEWER_SUGGESTION_APPROVE, + icon: 'Add', + }); + + return actions; + } + + return { + getItemActions, + reviewerSuggestionApprove, + }; +} diff --git a/src/pages/workflow/WorkflowPageOJS.vue b/src/pages/workflow/WorkflowPageOJS.vue index 2f707ed34..bf4bc16d1 100644 --- a/src/pages/workflow/WorkflowPageOJS.vue +++ b/src/pages/workflow/WorkflowPageOJS.vue @@ -13,6 +13,7 @@ import ReviewerManager from '@/managers/ReviewerManager/ReviewerManager.vue'; import DiscussionManager from '@/managers/DiscussionManager/DiscussionManager.vue'; import ContributorManager from '@/managers/ContributorManager/ContributorManager.vue'; import ParticipantManager from '@/managers/ParticipantManager/ParticipantManager.vue'; +import ReviewerSuggestionManager from '@/managers/ReviewerSuggestionManager/ReviewerSuggestionManager.vue'; import GalleyManager from '@/managers/GalleyManager/GalleyManager.vue'; import WorkflowActionButton from './components/action/WorkflowActionButton.vue'; import WorkflowRecommendOnlyControls from './components/action/WorkflowRecommendOnlyControls.vue'; @@ -42,6 +43,7 @@ const Components = markRaw({ DiscussionManager, ContributorManager, ParticipantManager, + ReviewerSuggestionManager, GalleyManager, WorkflowActionButton, WorkflowRecommendOnlyControls, diff --git a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js index 6e21e56fc..9118a3269 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js @@ -28,6 +28,7 @@ export function useWorkflowConfigOJS({dashboardPage}) { if (selectedMenuState.stageId) { const itemsArgs = { submission, + pageInitConfig, selectedPublication, selectedPublicationId, selectedStageId: selectedMenuState.stageId, diff --git a/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js b/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js index 01cb9447e..6d05b07d3 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js @@ -280,7 +280,12 @@ export const WorkflowConfig = { return items; }, - getSecondaryItems: ({submission, selectedReviewRound, selectedStageId}) => { + getSecondaryItems: ({ + submission, + selectedReviewRound, + selectedStageId, + pageInitConfig, + }) => { const items = []; if (!selectedReviewRound) { return []; @@ -299,6 +304,7 @@ export const WorkflowConfig = { }, }); } + items.push({ component: 'ParticipantManager', props: { @@ -307,6 +313,17 @@ export const WorkflowConfig = { }, }); + if (pageInitConfig.publicationSettings.isReviewerSuggestionEnabled) { + items.push({ + component: 'ReviewerSuggestionManager', + props: { + submission, + submissionStageId: selectedStageId, + reviewRoundId: selectedReviewRound.id, + }, + }); + } + return items; }, getActionItems: ({submission, selectedStageId, selectedReviewRound}) => {