From 664f8655b9b000a1a9879d8ce87ff2a81d658151 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 19 Nov 2024 13:40:24 +0600 Subject: [PATCH] pkp/pkp-lib#1660 remove static recommendations and added dymanic recommendations pulling --- public/globals.js | 12 +++--- src/composables/useSubmission.js | 40 +++++++++---------- .../ReviewerManager/ReviewerManager.vue | 1 + .../ReviewerManager/reviewerManagerStore.js | 4 +- .../useReviewerManagerConfig.js | 30 ++++++++------ src/pages/dashboard/DashboardPage.vue | 5 +++ .../composables/useReviewActivityLogic.js | 17 ++++---- src/pages/dashboard/dashboardPageStore.js | 2 +- .../useWorkflowConfig/useWorkflowConfigOJS.js | 1 + .../workflowConfigEditorialOJS.js | 8 +++- 10 files changed, 70 insertions(+), 50 deletions(-) diff --git a/public/globals.js b/public/globals.js index 0c8538abb..ce457ba21 100644 --- a/public/globals.js +++ b/public/globals.js @@ -67,12 +67,12 @@ window.pkp = { SUBMISSION_REVIEW_METHOD_DOUBLEANONYMOUS: 2, SUBMISSION_REVIEW_METHOD_OPEN: 3, - SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT: 1, - SUBMISSION_REVIEWER_RECOMMENDATION_PENDING_REVISIONS: 2, - SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_HERE: 3, - SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_ELSEWHERE: 4, - SUBMISSION_REVIEWER_RECOMMENDATION_DECLINE: 5, - SUBMISSION_REVIEWER_RECOMMENDATION_SEE_COMMENTS: 6, + // SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT: 1, + // SUBMISSION_REVIEWER_RECOMMENDATION_PENDING_REVISIONS: 2, + // SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_HERE: 3, + // SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_ELSEWHERE: 4, + // SUBMISSION_REVIEWER_RECOMMENDATION_DECLINE: 5, + // SUBMISSION_REVIEWER_RECOMMENDATION_SEE_COMMENTS: 6, ROLE_ID_MANAGER: 16, ROLE_ID_SITE_ADMIN: 1, diff --git a/src/composables/useSubmission.js b/src/composables/useSubmission.js index 5416538e3..32fddca0c 100644 --- a/src/composables/useSubmission.js +++ b/src/composables/useSubmission.js @@ -25,26 +25,26 @@ export const ExtendedStagesLabels = { declined: tk('submissions.declined'), }; -export const RecommendationTranslations = { - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT]: tk( - 'reviewer.article.decision.accept', - ), - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_PENDING_REVISIONS]: tk( - 'reviewer.article.decision.pendingRevisions', - ), - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_HERE]: tk( - 'reviewer.article.decision.resubmitHere', - ), - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_ELSEWHERE]: tk( - 'reviewer.article.decision.resubmitElsewhere', - ), - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_DECLINE]: tk( - 'reviewer.article.decision.decline', - ), - [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_SEE_COMMENTS]: tk( - 'reviewer.article.decision.seeComments', - ), -}; +// export const RecommendationTranslations = { +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT]: tk( +// 'reviewer.article.decision.accept', +// ), +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_PENDING_REVISIONS]: tk( +// 'reviewer.article.decision.pendingRevisions', +// ), +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_HERE]: tk( +// 'reviewer.article.decision.resubmitHere', +// ), +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_RESUBMIT_ELSEWHERE]: tk( +// 'reviewer.article.decision.resubmitElsewhere', +// ), +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_DECLINE]: tk( +// 'reviewer.article.decision.decline', +// ), +// [pkp.const.SUBMISSION_REVIEWER_RECOMMENDATION_SEE_COMMENTS]: tk( +// 'reviewer.article.decision.seeComments', +// ), +// }; const InProgressReviewAssignmentStatuses = [ pkp.const.REVIEW_ASSIGNMENT_STATUS_ACCEPTED, diff --git a/src/managers/ReviewerManager/ReviewerManager.vue b/src/managers/ReviewerManager/ReviewerManager.vue index f42bc8f4e..3bf3d9e8b 100644 --- a/src/managers/ReviewerManager/ReviewerManager.vue +++ b/src/managers/ReviewerManager/ReviewerManager.vue @@ -100,6 +100,7 @@ const props = defineProps({ submission: {type: Object, required: true}, reviewRoundId: {type: Number, required: true}, redactedForAuthors: {type: Boolean, required: false, default: false}, + recommendations: {type: Array, required: true}, }); const reviewerStore = useReviewerManagerStore(props); diff --git a/src/managers/ReviewerManager/reviewerManagerStore.js b/src/managers/ReviewerManager/reviewerManagerStore.js index 0a3bfa350..e1ec492cc 100644 --- a/src/managers/ReviewerManager/reviewerManagerStore.js +++ b/src/managers/ReviewerManager/reviewerManagerStore.js @@ -35,7 +35,9 @@ export const useReviewerManagerStore = defineComponentStore( /** * Config */ - const {getCellStatusItems} = useReviewerManagerConfig(); + const {getCellStatusItems} = useReviewerManagerConfig( + props.recommendations, + ); /** * Actions diff --git a/src/managers/ReviewerManager/useReviewerManagerConfig.js b/src/managers/ReviewerManager/useReviewerManagerConfig.js index 82d965561..87962e32d 100644 --- a/src/managers/ReviewerManager/useReviewerManagerConfig.js +++ b/src/managers/ReviewerManager/useReviewerManagerConfig.js @@ -1,25 +1,31 @@ import {useLocalize} from '@/composables/useLocalize'; import {useDate} from '@/composables/useDate'; -import {RecommendationTranslations} from '@/composables/useSubmission'; -export function useReviewerManagerConfig() { - const {t} = useLocalize(); +// import {RecommendationTranslations} from '@/composables/useSubmission'; +export function useReviewerManagerConfig(recommendations) { + const {t, localize} = useLocalize(); const {formatShortDate} = useDate(); function getCellStatusItems({reviewAssignment}) { const items = []; function getRecommendationString(reviewAssignment) { - const recommendationString = reviewAssignment.recommendation - ? t(RecommendationTranslations[reviewAssignment.recommendation]) - : null; + // const recommendationString = reviewAssignment.recommendation + // ? t(RecommendationTranslations[reviewAssignment.recommendation]) + // : null; - if (recommendationString) { - return t('submission.recommendation', { - recommendation: recommendationString, - }); - } + // if (recommendationString) { + // return t('submission.recommendation', { + // recommendation: recommendationString, + // }); + // } + + // return null; + + const recommendation = recommendations.filter( + (r) => r.value === reviewAssignment.recommendation, + )[0]; - return null; + return recommendation ? localize(recommendation.title) : null; } function getCompetingInterests(reviewAssignment) { diff --git a/src/pages/dashboard/DashboardPage.vue b/src/pages/dashboard/DashboardPage.vue index 3b58c8e8d..fb511bb8b 100644 --- a/src/pages/dashboard/DashboardPage.vue +++ b/src/pages/dashboard/DashboardPage.vue @@ -92,6 +92,11 @@ const props = defineProps({ type: Object, required: true, }, + /** context available reviewer recommendations */ + recommendations: { + type: Array, + required: true, + }, }); const store = useDashboardPageStore(props); diff --git a/src/pages/dashboard/composables/useReviewActivityLogic.js b/src/pages/dashboard/composables/useReviewActivityLogic.js index f07dd47df..dd7cf7141 100644 --- a/src/pages/dashboard/composables/useReviewActivityLogic.js +++ b/src/pages/dashboard/composables/useReviewActivityLogic.js @@ -1,11 +1,8 @@ import {useLocalize} from '@/composables/useLocalize'; import {useDate} from '@/composables/useDate'; -import { - useSubmission, - RecommendationTranslations, -} from '@/composables/useSubmission'; +import {useSubmission} from '@/composables/useSubmission'; import {Actions as ReviewerManagerActions} from '@/managers/ReviewerManager/useReviewerManagerActions'; -const {tk, t} = useLocalize(); +const {tk, t, localize} = useLocalize(); const {calculateDaysBetweenDates} = useDate(); const ReviewActivityActions = { @@ -282,7 +279,7 @@ function getDays(config, reviewAssignment) { return null; } -export function useReviewActivityLogic() { +export function useReviewActivityLogic(recommendations) { function getReviewActivityIndicatorProps(reviewAssignment) { const config = ConfigPerStatus[reviewAssignment.statusId]; @@ -323,9 +320,11 @@ export function useReviewActivityLogic() { const date = getDate(config, reviewAssignment); function getRecommendation() { - return RecommendationTranslations[reviewAssignment.recommendation] - ? t(RecommendationTranslations[reviewAssignment.recommendation]) - : null; + const recommendation = recommendations.filter( + (r) => r.value === reviewAssignment.recommendation, + )[0]; + + return recommendation ? localize(recommendation.title) : null; } const days = getDays(config, reviewAssignment); diff --git a/src/pages/dashboard/dashboardPageStore.js b/src/pages/dashboard/dashboardPageStore.js index 7fb681a76..dee1b9ed2 100644 --- a/src/pages/dashboard/dashboardPageStore.js +++ b/src/pages/dashboard/dashboardPageStore.js @@ -363,7 +363,7 @@ export const useDashboardPageStore = defineComponentStore( const { getReviewActivityIndicatorProps, getReviewActivityIndicatorPopoverProps, - } = useReviewActivityLogic(); + } = useReviewActivityLogic(pageInitConfig.recommendations); return { // Dashboard diff --git a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js index 7ee8c7e4d..81c51dc27 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js @@ -53,6 +53,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 5b0bd18cf..a6899dc7c 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOJS.js @@ -188,7 +188,12 @@ export const WorkflowConfig = { }, [pkp.const.WORKFLOW_STAGE_ID_EXTERNAL_REVIEW]: { - getPrimaryItems: ({submission, selectedStageId, selectedReviewRound}) => { + getPrimaryItems: ({ + submission, + selectedStageId, + selectedReviewRound, + pageInitConfig, + }) => { const items = []; if (!selectedReviewRound) { return [ @@ -248,6 +253,7 @@ export const WorkflowConfig = { props: { submission: submission, reviewRoundId: selectedReviewRound?.id, + recommendations: pageInitConfig.recommendations, }, });