From bd9181ea87a59534301ee18996382d2f72ccb243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Thu, 29 Aug 2024 15:26:12 +0200 Subject: [PATCH] Submission listing WIP --- src/composables/useSubmission.js | 9 + src/managers/FileManager/fileManagerStore.js | 2 +- .../SubmissionSummaryModal.vue | 5 +- .../composables/useEditorPublicationConfig.js | 87 ++++++- .../composables/useEditorWorkflowConfig.js | 50 ++-- .../composables/useSummarySideNav.js | 3 +- .../primaryItems/PublicationEditDisabled.vue | 13 + .../primaryItems/SubmissionStatus.vue | 40 +++ .../submissionSummaryStore.js | 16 +- .../composables/useEditorialLogic.js | 7 +- .../dashboard/composables/useHandleActions.js | 234 ++++++++++-------- .../composables/useReviewActivityLogic.js | 50 ++-- src/pages/dashboard/dashboardPageStore.js | 11 +- 13 files changed, 351 insertions(+), 176 deletions(-) create mode 100644 src/pages/dashboard/SubmissionSummaryModal/primaryItems/PublicationEditDisabled.vue create mode 100644 src/pages/dashboard/SubmissionSummaryModal/primaryItems/SubmissionStatus.vue diff --git a/src/composables/useSubmission.js b/src/composables/useSubmission.js index c8b28f456..9a60a4267 100644 --- a/src/composables/useSubmission.js +++ b/src/composables/useSubmission.js @@ -71,6 +71,14 @@ export function useSubmission() { ); } + function getLatestPublication(submission) { + return submission.publications.reduce( + (latestPublication, publication) => + publication.id > latestPublication.id ? publication : latestPublication, + submission.publications[0], + ); + } + function getExtendedStage(submission) { const activeStage = getActiveStage(submission); @@ -137,6 +145,7 @@ export function useSubmission() { getReviewRoundsForStage, getCurrentReviewAssignments, getCurrentPublication, + getLatestPublication, getFileStageFromWorkflowStage, hasNotSubmissionStartedStage, hasSubmissionPassedStage, diff --git a/src/managers/FileManager/fileManagerStore.js b/src/managers/FileManager/fileManagerStore.js index a32683e05..780add801 100644 --- a/src/managers/FileManager/fileManagerStore.js +++ b/src/managers/FileManager/fileManagerStore.js @@ -29,7 +29,7 @@ export const useFileManagerStore = defineComponentStore( const {data, fetch: fetchFiles} = useFetch(filesApiUrl, { query: { fileStages: managerConfig.value.fileStage, - reviewRoundId: props.reviewRoundId ? props.reviewRoundId : undefined, + reviewRoundIds: props.reviewRoundId ? props.reviewRoundId : undefined, }, }); diff --git a/src/pages/dashboard/SubmissionSummaryModal/SubmissionSummaryModal.vue b/src/pages/dashboard/SubmissionSummaryModal/SubmissionSummaryModal.vue index 14e45fddd..853ef4cad 100644 --- a/src/pages/dashboard/SubmissionSummaryModal/SubmissionSummaryModal.vue +++ b/src/pages/dashboard/SubmissionSummaryModal/SubmissionSummaryModal.vue @@ -116,7 +116,8 @@ import PublicationVersionControl from './publicationControls/PublicationVersionC import ActionButton from './actionItems/ActionButton.vue'; import EditorsAssigned from './metaItems/EditorsAssigned.vue'; import BasicMetadata from './metaItems/BasicMetadata.vue'; - +import SubmissionStatus from './primaryItems/SubmissionStatus.vue'; +import PublicationEditDisabled from './primaryItems/PublicationEditDisabled.vue'; import IssueAssigned from './metaItems/IssueAssigned.vue'; import {useSubmissionSummaryStore} from './submissionSummaryStore'; import SideModalLayoutMenu2Columns from '@/components/Modal/SideModalLayoutMenu2Columns.vue'; @@ -140,6 +141,8 @@ const Components = { ReviewRoundStatus, PublicationTitleAbstractForm, PublicationVersionControl, + SubmissionStatus, + PublicationEditDisabled, }; const props = defineProps({ diff --git a/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorPublicationConfig.js b/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorPublicationConfig.js index 97bf62f03..a791f2e7c 100644 --- a/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorPublicationConfig.js +++ b/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorPublicationConfig.js @@ -1,4 +1,6 @@ import {useLocalize} from '@/composables/useLocalize'; +import {Actions} from '../../composables/useHandleActions'; +import {useSubmission} from '@/composables/useSubmission'; export const PublicationConfig = { titleAbstract: { getPrimaryItems: ({submission, selectedPublication, pageInitConfig}) => { @@ -62,9 +64,18 @@ export const PublicationConfig = { export function useEditorPublicationConfig() { function getPrimaryItems(args) { - return PublicationConfig[args.selectedPublicationMenu].getPrimaryItems( - args, - ); + const items = []; + if (args.selectedPublication.status === pkp.const.STATUS_PUBLISHED) { + items.push({ + component: 'PublicationEditDisabled', + props: {}, + }); + } + + return [ + ...items, + ...PublicationConfig[args.selectedPublicationMenu].getPrimaryItems(args), + ]; } function getPublicationControlsLeft({ @@ -91,15 +102,67 @@ export function useEditorPublicationConfig() { }) { const items = []; const {t} = useLocalize(); - items.push({ - component: 'ActionButton', - props: { - label: t('dashboard.summary.scheduleForPublication'), - isPrimary: true, - //action: 'scheduleForPublication', - action: 'assignToIssueAndScheduleForPublication', - }, - }); + + if (selectedPublication.status === pkp.const.STATUS_QUEUED) { + items.push({ + component: 'ActionButton', + props: { + label: t('dashboard.summary.preview'), + isSecondary: true, + action: Actions.PREVIEW_PUBLICATION, + }, + }); + + items.push({ + component: 'ActionButton', + props: { + label: t('editor.submission.schedulePublication'), + isSecondary: true, + action: Actions.ASSIGN_TO_ISSUE_AND_SCHEULE_FOR_PUBLICATION, + }, + }); + } else if (selectedPublication.status === pkp.const.STATUS_SCHEDULED) { + items.push({ + component: 'ActionButton', + props: { + label: t('dashboard.summary.preview'), + isSecondary: true, + action: Actions.PREVIEW_PUBLICATION, + }, + }); + + items.push({ + component: 'ActionButton', + props: { + label: t('publication.unschedule'), + isWarnable: true, + action: Actions.UNSCHEDULE_PUBLICATION, + }, + }); + } else if (selectedPublication.status === pkp.const.STATUS_PUBLISHED) { + items.push({ + component: 'ActionButton', + props: { + label: t('publication.unpublish'), + isWarnable: true, + action: Actions.UNPUBLISH_PUBLICATION, + }, + }); + + const {getLatestPublication} = useSubmission(); + const latestPublication = getLatestPublication(submission); + + if (latestPublication.id === selectedPublication.id) { + items.push({ + component: 'ActionButton', + props: { + label: t('publication.createVersion'), + isSecondary: true, + action: Actions.CREATE_NEW_VERSION, + }, + }); + } + } return items; } diff --git a/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorWorkflowConfig.js b/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorWorkflowConfig.js index 00f07016f..dc634537c 100644 --- a/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorWorkflowConfig.js +++ b/src/pages/dashboard/SubmissionSummaryModal/composables/useEditorWorkflowConfig.js @@ -7,16 +7,7 @@ export function useEditorWorkflowConfig() { const {hasSubmissionPassedStage, hasNotSubmissionStartedStage} = useSubmission(); - function getPrimaryItems({ - submission, - currentPublication, - selectedStageId, - selectedReviewRound, - }) { - //const activeStage = getActiveStage(submission); - - //const isSelectedStageActive = selectedStageId === activeStage.id; - + function getPrimaryItems({submission, selectedStageId, selectedReviewRound}) { const items = []; if (selectedStageId === pkp.const.WORKFLOW_STAGE_ID_SUBMISSION) { @@ -26,14 +17,7 @@ export function useEditorWorkflowConfig() { pkp.const.WORKFLOW_STAGE_ID_SUBMISSION, ) ) { - items.push({ - component: 'PrimaryBasicMetadata', - props: { - body: t( - 'editor.submission.workflowDecision.submission.underReview', - ), - }, - }); + items.push({component: 'SubmissionStatus', props: {submission}}); } items.push({ @@ -161,6 +145,14 @@ export function useEditorWorkflowConfig() { }, }); } else if (selectedStageId === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION) { + if (submission.status === pkp.const.STATUS_PUBLISHED) { + items.push({ + component: 'PrimaryBasicMetadata', + props: { + body: t('editor.submission.workflowDecision.submission.published'), + }, + }); + } items.push({ component: 'FileManager', props: { @@ -369,20 +361,22 @@ export function useEditorWorkflowConfig() { items.push({ component: 'ActionButton', props: { - label: t('dashboard.summary.scheduleForPublication'), + label: t('editor.submission.schedulePublication'), isPrimary: true, - action: 'scheduleForPublication', + action: 'navigateToMenu', + actionArgs: {key: 'publication_titleAbstract'}, }, }); - items.push({ - component: 'ActionButton', - props: { - label: t('dashboard.summary.backToCopyediting'), - isWarnable: true, - action: 'decisionBackFromProduction', - }, - }); + if (submission.status === pkp.const.STATUS_QUEUED) + items.push({ + component: 'ActionButton', + props: { + label: t('dashboard.summary.backToCopyediting'), + isWarnable: true, + action: 'decisionBackFromProduction', + }, + }); } return items; } diff --git a/src/pages/dashboard/SubmissionSummaryModal/composables/useSummarySideNav.js b/src/pages/dashboard/SubmissionSummaryModal/composables/useSummarySideNav.js index 8fe65a3c8..991aafccb 100644 --- a/src/pages/dashboard/SubmissionSummaryModal/composables/useSummarySideNav.js +++ b/src/pages/dashboard/SubmissionSummaryModal/composables/useSummarySideNav.js @@ -136,7 +136,8 @@ export function useSummarySideNav() { label: 'Production', title: getWorkflowTitle(pkp.const.WORKFLOW_STAGE_ID_PRODUCTION), colorStripe: - activeStage.id === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION + activeStage.id === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION && + submission.status === pkp.const.STATUS_QUEUED ? 'border-stage-copyediting' : null, action: 'selectStage', diff --git a/src/pages/dashboard/SubmissionSummaryModal/primaryItems/PublicationEditDisabled.vue b/src/pages/dashboard/SubmissionSummaryModal/primaryItems/PublicationEditDisabled.vue new file mode 100644 index 000000000..bb062244e --- /dev/null +++ b/src/pages/dashboard/SubmissionSummaryModal/primaryItems/PublicationEditDisabled.vue @@ -0,0 +1,13 @@ + + + diff --git a/src/pages/dashboard/SubmissionSummaryModal/primaryItems/SubmissionStatus.vue b/src/pages/dashboard/SubmissionSummaryModal/primaryItems/SubmissionStatus.vue new file mode 100644 index 000000000..2d083cc66 --- /dev/null +++ b/src/pages/dashboard/SubmissionSummaryModal/primaryItems/SubmissionStatus.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/pages/dashboard/SubmissionSummaryModal/submissionSummaryStore.js b/src/pages/dashboard/SubmissionSummaryModal/submissionSummaryStore.js index bd849dba4..77ca84dc3 100644 --- a/src/pages/dashboard/SubmissionSummaryModal/submissionSummaryStore.js +++ b/src/pages/dashboard/SubmissionSummaryModal/submissionSummaryStore.js @@ -73,6 +73,11 @@ export const useSubmissionSummaryStore = defineComponentStore( )?.id }`, ); + } else if ( + newSubmission.stageId === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION && + newSubmission.status !== pkp.const.STATUS_QUEUED + ) { + setActiveItemKey(`publication_titleAbstract`); } else { setActiveItemKey(`workflow_${newSubmission.stageId}`); } @@ -128,6 +133,11 @@ export const useSubmissionSummaryStore = defineComponentStore( const {handleSubmissionAction} = useHandleActions(props.pageInitConfig); function handleAction(actionName, _actionArgs) { + if (actionName === 'navigateToMenu') { + setActiveItemKey(_actionArgs.key); + return; + } + const actionArgs = { ..._actionArgs, submission: submission.value, @@ -212,7 +222,11 @@ export const useSubmissionSummaryStore = defineComponentStore( }); const publicationControlsRight = computed(() => { - if (!submission.value || !selectedMenuState.value.publicationMenu) { + if ( + !submission.value || + !selectedPublication.value || + !selectedMenuState.value.publicationMenu + ) { return []; } diff --git a/src/pages/dashboard/composables/useEditorialLogic.js b/src/pages/dashboard/composables/useEditorialLogic.js index a1220a427..389ebd1af 100644 --- a/src/pages/dashboard/composables/useEditorialLogic.js +++ b/src/pages/dashboard/composables/useEditorialLogic.js @@ -1,6 +1,7 @@ import {useSubmission} from '@/composables/useSubmission.js'; import {useLocalize} from '@/composables/useLocalize'; import {useDate} from '@/composables/useDate'; +import {Actions} from './useHandleActions'; const {formatShortDate} = useDate(); @@ -18,7 +19,7 @@ export function useEditorialLogic() { { component: 'CellSubmissionActivityActionAlert', props: { - actionName: 'assignParticipant', + actionName: Actions.ASSIGN_PARTICIPANT, actionLabel: t('dashboard.assignEditor'), }, }, @@ -34,7 +35,7 @@ export function useEditorialLogic() { { component: 'CellSubmissionActivityActionAlert', props: { - actionName: 'assignReviewers', + actionName: Actions.ASSIGN_REVIEWERS, actionLabel: t('dashboard.assignReviewers'), }, }, @@ -137,7 +138,7 @@ export function useEditorialLogic() { props: { alert: t('dashboard.revisionRequested'), actionLabel: t('dashboard.submitRevisions'), - actionName: 'uploadRevisions', + actionName: Actions.UPLOAD_REVISIONS, }, }, ]; diff --git a/src/pages/dashboard/composables/useHandleActions.js b/src/pages/dashboard/composables/useHandleActions.js index d4c7362a2..472b79f2b 100644 --- a/src/pages/dashboard/composables/useHandleActions.js +++ b/src/pages/dashboard/composables/useHandleActions.js @@ -7,44 +7,83 @@ import {useFetch} from '@/composables/useFetch'; import {useUrlSearchParams} from '@vueuse/core'; import {useLegacyGridUrl} from '@/composables/useLegacyGridUrl'; +export const Actions = { + DECISION_ACCEPT: 'decisionAccept', + DECISION_CANCEL_REVIEW_ROUND: 'decisionCancelReviewRound', + DECISION_DECLINE_SUBMISSION: 'decisionDeclineSubmission', + DECISION_EXTERNAL_REVIEW: 'decisionExternalReview', + DECISION_SKIP_EXTERNAL_REVIEW: 'decisionSkipExternalReview', + DECISION_INITIAL_DECLINE: 'decisionInitialDecline', + DECISION_SEND_TO_PRODUCTION: 'decisionSendToProduction', + DECISION_BACK_FROM_COPYEDITING: 'decisionBackFromCopyediting', + DECISION_NEW_EXTERNAL_ROUND: 'decisionNewExternalRound', + DECISION_BACK_FROM_PRODUCTION: 'decisionBackFromProduction', + + REQUEST_REVISION: 'requestRevisions', + ASSIGN_REVIEWERS: 'assignReviewers', + UNASSIGN_REVIEWER: 'unassignReviewer', + CANCEL_REVIEWER: 'cancelReviewer', + RESEND_REVIEW_REQUEST: 'resendReviewRequest', + + // TODO rename so its clear whats that for + VIEW_DETAILS: 'viewDetails', + VIEW_UNREAD_RECOMMENDATION: 'viewUnreadRecommendation', + VIEW_RECOMMENDATION: 'viewRecommendation', + + EDIT_DUE_DATE: 'editDueDate', + ASSIGN_TO_ISSUE: 'assignToIssue', + VIEW_ACTIVITY_LOG: 'viewActivityLog', + ASSIGN_PARTICIPANT: 'assignParticipant', + UPLOAD_REVISIONS: 'uploadRevisions', + OPEN_REVIEW_FORM: 'openReviewForm', + UPLOAD_REVIEWER_FILE: 'uploadReviewerFile', + ASSIGN_TO_ISSUE_AND_SCHEULE_FOR_PUBLICATION: + 'assignToIssueAndScheduleForPublication', + SCHEDULE_FOR_PUBLICATION: 'scheduleForPublication', + PREVIEW_PUBLICATION: 'previewPublication', + UNSCHEDULE_PUBLICATION: 'unschedulePublication', + UNPUBLISH_PUBLICATION: 'unpublichPublication', + CREATE_NEW_VERSION: 'createNewVersion', +}; + import SelectRevisionRecommendationFormModal from '../components/SelectRevisionRecommendationFormModal.vue'; export function useHandleActions({selectRevisionDecisionForm}) { function handleSubmissionAction(actionName, actionArgs, finishedCallback) { const {submission, selectedPublication} = actionArgs; const {openSideModal, openDialog} = useModal(); const {t, localize} = useLocalize(); - const {getCurrentReviewRound} = useSubmission(); + const {getCurrentReviewRound, getLatestPublication} = useSubmission(); const editorialDecisionActions = { requestRevisions: {}, - decisionAccept: { + [Actions.DECISION_ACCEPT]: { decisionId: pkp.const.DECISION_ACCEPT, }, - decisionCancelReviewRound: { + [Actions.DECISION_CANCEL_REVIEW_ROUND]: { decisionId: pkp.const.DECISION_CANCEL_REVIEW_ROUND, }, - declineSubmission: { + [Actions.DECISION_DECLINE_SUBMISSION]: { decisionId: pkp.const.DECISION_DECLINE, }, - decisionExternalReview: { + [Actions.DECISION_EXTERNAL_REVIEW]: { decisionId: pkp.const.DECISION_EXTERNAL_REVIEW, }, - decisionSkipExternalReview: { + [Actions.DECISION_SKIP_EXTERNAL_REVIEW]: { decisionId: pkp.const.DECISION_SKIP_EXTERNAL_REVIEW, }, - decisionInitialDecline: { + [Actions.DECISION_INITIAL_DECLINE]: { decisionId: pkp.const.DECISION_INITIAL_DECLINE, }, - decisionSendToProduction: { + [Actions.DECISION_SEND_TO_PRODUCTION]: { decisionId: pkp.const.DECISION_SEND_TO_PRODUCTION, }, - decisionBackFromCopyediting: { + [Actions.DECISION_BACK_FROM_COPYEDITING]: { decisionId: pkp.const.DECISION_BACK_FROM_COPYEDITING, }, - decisionNewExternalRound: { + [Actions.DECISION_NEW_EXTERNAL_ROUND]: { decisionId: pkp.const.DECISION_NEW_EXTERNAL_ROUND, }, - decisionBackFromProduction: { + [Actions.DECISION_BACK_FROM_PRODUCTION]: { decisionId: pkp.const.DECISION_BACK_FROM_PRODUCTION, }, }; @@ -72,8 +111,13 @@ export function useHandleActions({selectRevisionDecisionForm}) { redirectToPage(); } + console.log( + 'actionName:', + actionName, + editorialDecisionActions[actionName], + ); if (editorialDecisionActions[actionName]) { - if (actionName === 'requestRevisions') { + if (actionName === Actions.REQUEST_REVISION) { // open modal const {set, form, getValue} = useForm(selectRevisionDecisionForm); openSideModal(SelectRevisionRecommendationFormModal, { @@ -99,7 +143,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { // redirect to decisions page } - if (actionName === 'assignReviewers') { + if (actionName === Actions.ASSIGN_REVIEWERS) { const activeReviewRound = getCurrentReviewRound(submission); const {url} = useLegacyGridUrl({ @@ -117,7 +161,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { 'LegacyAjax', { legacyOptions: { - title: t('editor.submission.addStageParticipant'), + title: t('editor.submission.addReviewer'), url: url.value, }, }, @@ -127,7 +171,9 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (['unassignReviewer', 'cancelReviewer'].includes(actionName)) { + } else if ( + [Actions.UNASSIGN_REVIEWER, Actions.CANCEL_REVIEWER].includes(actionName) + ) { const {url} = useLegacyGridUrl({ component: 'grid.users.reviewer.ReviewerGridHandler', op: 'unassignReviewer', @@ -140,7 +186,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }); const modalTitle = - actionName === 'unassignReviewer' + actionName === Actions.UNASSIGN_REVIEWER ? t('editor.review.unassignReviewer') : t('editor.review.cancelReviewer'); @@ -155,7 +201,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'resendReviewRequest') { + } else if (actionName === Actions.RESEND_REVIEW_REQUEST) { const {url} = useLegacyGridUrl({ component: 'grid.users.reviewer.ReviewerGridHandler', op: 'resendRequestReviewer', @@ -179,9 +225,9 @@ export function useHandleActions({selectRevisionDecisionForm}) { ); } else if ( [ - 'viewDetails', - 'viewUnreadRecommendation', - 'viewRecommendation', + Actions.VIEW_DETAILS, + Actions.VIEW_UNREAD_RECOMMENDATION, + Actions.VIEW_RECOMMENDATION, ].includes(actionName) ) { const {url} = useLegacyGridUrl({ @@ -194,13 +240,11 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }); - const {getCurrentPublication} = useSubmission(); - openSideModal( 'LegacyAjax', { legacyOptions: { - title: `${t('editor.review.reviewDetails')}: ${localize(getCurrentPublication(submission).fullTitle)}`, + title: `${t('editor.review.reviewDetails')}: ${localize(selectedPublication.fullTitle)}`, url, }, }, @@ -210,7 +254,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'editDueDate') { + } else if (actionName === Actions.EDIT_DUE_DATE) { const {url} = useLegacyGridUrl({ component: 'grid.users.reviewer.ReviewerGridHandler', op: 'editReview', @@ -232,14 +276,13 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'assignToIssue') { - const {getCurrentPublication} = useSubmission(); + } else if (actionName === Actions.ASSIGN_TO_ISSUE) { const {url} = useLegacyGridUrl({ component: 'modals.publish.AssignToIssueHandler', op: 'assign', params: { submissionId: submission.id, - publicationId: getCurrentPublication(submission).id, + publicationId: selectedPublication.id, }, }); @@ -259,7 +302,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'viewActivityLog') { + } else if (actionName === Actions.VIEW_ACTIVITY_LOG) { const {url} = useLegacyGridUrl({ component: 'informationCenter.SubmissionInformationCenterHandler', op: 'viewInformationCenter', @@ -279,7 +322,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'assignParticipant') { + } else if (actionName === Actions.ASSIGN_PARTICIPANT) { const {url} = useLegacyGridUrl({ component: 'grid.users.stageParticipant.StageParticipantGridHandler', op: 'addParticipant', @@ -303,7 +346,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'uploadRevisions') { + } else if (actionName === Actions.UPLOAD_REVISIONS) { const activeReviewRound = getCurrentReviewRound(submission); const {getFileStageFromWorkflowStage} = useSubmission(); @@ -330,71 +373,23 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'openReviewForm') { + } else if (actionName === Actions.OPEN_REVIEW_FORM) { const {redirectToPage} = useUrl( `reviewer/submission/${encodeURIComponent(submission.id)}`, {}, ); redirectToPage(); - } else if (actionName === 'uploadReviewerFile') { - const activeReviewRound = getCurrentReviewRound(submission); - // fileStage=5&reviewRoundId=8&assocType=517&assocId=28&submissionId=10&stageId=3&uploaderRoles=16-1-17-4096 - const {url} = useLegacyGridUrl({ - component: 'wizard.fileUpload.FileUploadWizardHandler', - op: 'startWizard', - params: { - fileStage: pkp.const.SUBMISSION_FILE_REVIEW_ATTACHMENT, - reviewRoundId: activeReviewRound.id, - assocType: pkp.const.ASSOC_TYPE_REVIEW_ASSIGNMENT, - assocId: actionArgs.reviewAssignmentId, - submissionId: submission.id, - stageId: submission.stageId, - uploaderRoles: pkp.const.ROLE_ID_REVIEWER, - }, - }); - - openSideModal( - 'LegacyAjax', - { - legacyOptions: { - url, - title: t('editor.submissionReview.uploadAttachment'), - }, - }, - { - onClose: async () => { - finishedCallback(); - }, - }, - ); - } else if (actionName === 'declineReviewAssignment') { - //publicknowledge/en/reviewer/showDeclineReview/5 - const {pageUrl} = useUrl(`reviewer/showDeclineReview/${submission.id}`); - - openSideModal( - 'LegacyAjax', - { - legacyOptions: { - title: t('reviewer.submission.declineReview'), - url: pageUrl, - }, - }, - { - onClose: async () => { - finishedCallback(); - }, - }, - ); - } else if (actionName === 'assignToIssueAndScheduleForPublication') { + } else if ( + actionName === Actions.ASSIGN_TO_ISSUE_AND_SCHEULE_FOR_PUBLICATION + ) { if (selectedPublication.issueId === null) { - const {getCurrentPublication} = useSubmission(); const {url} = useLegacyGridUrl({ component: 'modals.publish.AssignToIssueHandler', op: 'assign', params: { submissionId: submission.id, - publicationId: getCurrentPublication(submission).id, + publicationId: selectedPublication.id, }, }); @@ -411,7 +406,7 @@ export function useHandleActions({selectRevisionDecisionForm}) { onClose: async ({formId, data}) => { if (data?.issueId) { handleSubmissionAction( - 'scheduleForPublication', + Actions.SCHEDULE_FOR_PUBLICATION, actionArgs, finishedCallback, ); @@ -423,20 +418,18 @@ export function useHandleActions({selectRevisionDecisionForm}) { ); } else { handleSubmissionAction( - 'scheduleForPublication', + Actions.SCHEDULE_FOR_PUBLICATION, actionArgs, finishedCallback, ); } - } else if (actionName === 'scheduleForPublication') { - const {getCurrentPublication} = useSubmission(); - + } else if (actionName === Actions.SCHEDULE_FOR_PUBLICATION) { const {url} = useLegacyGridUrl({ component: 'modals.publish.PublishHandler', op: 'publish', params: { submissionId: submission.id, - publicationId: getCurrentPublication(submission).id, + publicationId: selectedPublication.id, }, }); openSideModal( @@ -454,28 +447,34 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, }, ); - } else if (actionName === 'previewPublication') { - const {getCurrentPublication} = useSubmission(); - - const {redirectToPage} = useUrl( - getCurrentPublication(submission).urlPublished, - ); + } else if (actionName === Actions.PREVIEW_PUBLICATION) { + const {redirectToPage} = useUrl(selectedPublication.urlPublished); redirectToPage(); - } else if (actionName === 'unschedulePublication') { + } else if ( + [Actions.UNSCHEDULE_PUBLICATION, Actions.UNPUBLISH_PUBLICATION].includes( + actionName, + ) + ) { openDialog({ - title: t('publication.unschedule'), - message: t('publication.unschedule.confirm'), + title: + actionName === Actions.UNSCHEDULE_PUBLICATION + ? t('publication.unschedule') + : t('publication.unpublish'), + message: + actionName === Actions.UNSCHEDULE_PUBLICATION + ? t('publication.unschedule.confirm') + : t('publication.unpublish.confirm'), actions: [ { - label: t('publication.unschedule'), + label: + actionName === Actions.UNSCHEDULE_PUBLICATION + ? t('publication.unschedule') + : t('publication.unpublish'), isPrimary: true, callback: async (close) => { - const {getCurrentPublication} = useSubmission(); - - const currentPublication = getCurrentPublication(submission); const {apiUrl: unschedulePublicationApiUrl} = useUrl( - `submissions/${submission.id}/publications/${currentPublication.id}/unpublish`, + `submissions/${submission.id}/publications/${selectedPublication.id}/unpublish`, ); const {fetch} = useFetch(unschedulePublicationApiUrl, { method: 'PUT', @@ -491,6 +490,35 @@ export function useHandleActions({selectRevisionDecisionForm}) { }, ], }); + } else if (actionName === Actions.CREATE_NEW_VERSION) { + openDialog({ + title: t('publication.createVersion'), + message: t('publication.version.confirm'), + actions: [ + { + label: t('common.yes'), + isWarnable: true, + callback: async (close) => { + close(); + + const latestPublication = getLatestPublication(submission); + + const {apiUrl: createNewVersionUrl} = useUrl( + `submissions/${submission.id}/publications/${latestPublication.id}/version`, + ); + const {fetch} = useFetch(createNewVersionUrl, { + method: 'POST', + }); + await fetch(); + finishedCallback(); + }, + }, + { + label: t('common.no'), + callback: (close) => close(), + }, + ], + }); } } diff --git a/src/pages/dashboard/composables/useReviewActivityLogic.js b/src/pages/dashboard/composables/useReviewActivityLogic.js index 058f5c670..af8760d3e 100644 --- a/src/pages/dashboard/composables/useReviewActivityLogic.js +++ b/src/pages/dashboard/composables/useReviewActivityLogic.js @@ -1,7 +1,7 @@ import {useLocalize} from '@/composables/useLocalize'; import {useDate} from '@/composables/useDate'; import {useReviewAssignment} from '@/composables/useReviewAssignment'; - +import {Actions} from './useHandleActions'; const {tk, t} = useLocalize(); const {calculateDaysBetweenDates} = useDate(); @@ -89,9 +89,9 @@ const ConfigPerStatus = { descriptionKey: tk( 'dashboard.reviewAssignment.statusAwaitingResponse.description', ), - textAction: 'editDueDate', - primaryAction: 'viewDetails', - negativeAction: 'unassignReviewer', + textAction: Actions.EDIT_DUE_DATE, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.UNASSIGN_REVIEWER, dateToDisplay: 'dateResponseDue', }, // reviewer declined review request @@ -107,9 +107,9 @@ const ConfigPerStatus = { }, titleKey: tk('dashboard.reviewAssignment.statusDeclined.title'), descriptionKey: tk('dashboard.reviewAssignment.statusDeclined.description'), - textAction: 'resendReviewRequest', - primaryAction: 'viewDetails', - negativeAction: 'cancelReviewer', + textAction: Actions.RESEND_REVIEW_REQUEST, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.CANCEL_REVIEWER, dateToDisplay: 'dateConfirmed', }, // review not responded within due date @@ -126,9 +126,9 @@ const ConfigPerStatus = { descriptionKey: tk( 'dashboard.reviewAssignment.statusResponseOverdue.description', ), - textAction: 'editDueDate', - primaryAction: 'viewDetails', - negativeAction: 'unassignReviewer', + textAction: Actions.EDIT_DUE_DATE, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.UNASSIGN_REVIEWER, dateToDisplay: 'dateResponseDue', }, // reviewer has agreed to the review @@ -143,9 +143,9 @@ const ConfigPerStatus = { }, titleKey: tk('dashboard.reviewAssignment.statusAccepted.title'), descriptionKey: tk('dashboard.reviewAssignment.statusAccepted.description'), - textAction: 'editDueDate', - primaryAction: 'viewDetails', - negativeAction: 'unassignReviewer', + textAction: Actions.EDIT_DUE_DATE, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.UNASSIGN_REVIEWER, dateToDisplay: 'dateDue', }, // review not submitted within due date @@ -162,9 +162,9 @@ const ConfigPerStatus = { descriptionKey: tk( 'dashboard.reviewAssignment.statusReviewOverdue.description', ), - textAction: 'editDueDate', - primaryAction: 'viewDetails', - negativeAction: 'unassignReviewer', + textAction: Actions.EDIT_DUE_DATE, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.UNASSIGN_REVIEWER, dateToDisplay: 'dateDue', }, // review has been submitted @@ -181,7 +181,7 @@ const ConfigPerStatus = { titleKey: tk('dashboard.reviewAssignment.statusReceived.title'), descriptionKey: tk('dashboard.reviewAssignment.statusReceived.description'), textAction: null, - primaryAction: 'viewUnreadRecommendation', + primaryAction: Actions.VIEW_UNREAD_RECOMMENDATION, negativeAction: null, dateToDisplay: 'dateCompleted', }, @@ -199,7 +199,7 @@ const ConfigPerStatus = { titleKey: tk('dashboard.reviewAssignment.statusReceived.title'), descriptionKey: tk('dashboard.reviewAssignment.statusReceived.description'), textAction: null, - primaryAction: 'viewRecommendation', + primaryAction: Actions.VIEW_RECOMMENDATION, negativeAction: null, dateToDisplay: 'dateCompleted', }, @@ -220,7 +220,7 @@ const ConfigPerStatus = { // same as for STATUS_RECEIVED descriptionKey: tk('dashboard.reviewAssignment.statusComplete.description'), textAction: null, - primaryAction: 'viewRecommendation', + primaryAction: Actions.VIEW_RECOMMENDATION, negativeAction: null, dateToDisplay: 'dateCompleted', }, @@ -241,7 +241,7 @@ const ConfigPerStatus = { // same as for STATUS_RECEIVED descriptionKey: tk('dashboard.reviewAssignment.statusComplete.description'), textAction: null, - primaryAction: 'viewRecommendation', + primaryAction: Actions.VIEW_RECOMMENDATION, negativeAction: null, dateToDisplay: 'dateCompleted', }, @@ -261,8 +261,8 @@ const ConfigPerStatus = { descriptionKey: tk( 'dashboard.reviewAssignment.statusCancelled.description', ), - textAction: 'resendReviewRequest', - primaryAction: 'viewDetails', + textAction: Actions.RESEND_REVIEW_REQUEST, + primaryAction: Actions.VIEW_DETAILS, negativeAction: null, // TODO: its not tracked on backend dateToDisplay: 'dateCancelled', @@ -281,9 +281,9 @@ const ConfigPerStatus = { descriptionKey: tk( 'dashboard.reviewAssignment.statusRequestResend.description', ), - textAction: 'editDueDate', - primaryAction: 'viewDetails', - negativeAction: 'unassignReviewer', + textAction: Actions.EDIT_DUE_DATE, + primaryAction: Actions.VIEW_DETAILS, + negativeAction: Actions.UNASSIGN_REVIEWER, dateToDisplay: 'dateResponseDue', }, }; diff --git a/src/pages/dashboard/dashboardPageStore.js b/src/pages/dashboard/dashboardPageStore.js index 7d2b5aa85..e98b28946 100644 --- a/src/pages/dashboard/dashboardPageStore.js +++ b/src/pages/dashboard/dashboardPageStore.js @@ -14,6 +14,8 @@ import {useHandleActions} from './composables/useHandleActions'; import {useEditorialLogic} from './composables/useEditorialLogic'; import {useReviewActivityLogic} from './composables/useReviewActivityLogic'; +import {useSubmission} from '@/composables/useSubmission'; + import DashboardFiltersModal from '@/pages/dashboard/components/DashboardFiltersModal.vue'; import SubmissionSummaryModal from '@/pages/dashboard/SubmissionSummaryModal/SubmissionSummaryModal.vue'; @@ -174,12 +176,19 @@ export const useDashboardPageStore = defineComponentStore( ); const {handleSubmissionAction} = useHandleActions(pageInitConfig); + const {getCurrentPublication} = useSubmission(); function handleItemAction(actionName, actionArgs) { const submission = submissions.value.find( (submission) => submission.id === actionArgs.submissionId, ); + const selectedPublication = getCurrentPublication(submission); + const actionArgsExtended = { + ...actionArgs, + submission, + selectedPublication, + }; - handleSubmissionAction(submission, actionName, actionArgs, async () => { + handleSubmissionAction(actionName, actionArgsExtended, async () => { await fetchSubmissions(); }); }