From 727c30dbc8a56a0ccb64ab3e6d4df3c6be97d4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Thu, 17 Oct 2024 08:51:15 +0200 Subject: [PATCH] pkp/pkp-lib#7495 Separate workflowPage for OJS --- .../ContributorManager/ContributorManager.vue | 2 +- .../contributorManagerStore.js | 2 +- src/managers/GalleyManager/GalleyManager.vue | 2 +- .../GalleyManager/galleyManagerStore.js | 2 +- .../GalleyManager/useGalleyManagerActions.js | 12 +- .../useReviewerManagerActions.js | 2 + src/pages/workflow/WorkflowPage.vue | 2 +- src/pages/workflow/WorkflowPageOJS.vue | 15 + .../composables/useWorkflowActions.js | 3 +- .../useWorkflowConfig/useWorkflowConfigOJS.js | 23 +- .../useWorkflowDataSubmissionPublication.js | 9 + .../useWorkflowNavigation.js | 4 - .../useWorkflowNavigationConfigOJS.js | 4 + src/pages/workflow/workflowStoreOJS.js | 264 ++++++++++++++++++ src/pages/workflow/workflowStoreOMP.js | 5 - 15 files changed, 310 insertions(+), 41 deletions(-) create mode 100644 src/pages/workflow/WorkflowPageOJS.vue delete mode 100644 src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigation.js create mode 100644 src/pages/workflow/workflowStoreOJS.js diff --git a/src/managers/ContributorManager/ContributorManager.vue b/src/managers/ContributorManager/ContributorManager.vue index b3c94beb3..dd48b6527 100644 --- a/src/managers/ContributorManager/ContributorManager.vue +++ b/src/managers/ContributorManager/ContributorManager.vue @@ -13,7 +13,7 @@ const props = defineProps({ submission: {type: Object, required: true}, publication: {type: Object, required: true}, contributorForm: {type: Object, required: true}, - canEditPublication: {type: Boolean, required: true}, + canEdit: {type: Boolean, required: true}, }); const contributorManagerStore = useContributorManagerStore(props); diff --git a/src/managers/ContributorManager/contributorManagerStore.js b/src/managers/ContributorManager/contributorManagerStore.js index 7d23fe8c2..785d40739 100644 --- a/src/managers/ContributorManager/contributorManagerStore.js +++ b/src/managers/ContributorManager/contributorManagerStore.js @@ -23,7 +23,7 @@ export const useContributorManagerStore = defineComponentStore( const contributorsListPanelProps = computed(() => { return { - canEditPublication: props.canEditPublication, + canEditPublication: props.canEdit, form: form.value, id: 'contributors', items: props.publication.authors, diff --git a/src/managers/GalleyManager/GalleyManager.vue b/src/managers/GalleyManager/GalleyManager.vue index 47c74d04b..e19c7251e 100644 --- a/src/managers/GalleyManager/GalleyManager.vue +++ b/src/managers/GalleyManager/GalleyManager.vue @@ -69,7 +69,7 @@ const Components = { const props = defineProps({ publication: {type: Object, required: true}, submission: {type: Object, required: true}, - canEditPublication: {type: Boolean, required: true}, + canEdit: {type: Boolean, required: true}, }); const {t} = useLocalize(); diff --git a/src/managers/GalleyManager/galleyManagerStore.js b/src/managers/GalleyManager/galleyManagerStore.js index 935744a20..4e75137e6 100644 --- a/src/managers/GalleyManager/galleyManagerStore.js +++ b/src/managers/GalleyManager/galleyManagerStore.js @@ -106,7 +106,7 @@ export const useGalleyManagerStore = defineComponentStore( const _galleyActionsFns = useGalleyManagerActions(); function getActionArgs() { return { - canEditPublication: props.canEditPublication, + canEdit: props.canEdit, }; } diff --git a/src/managers/GalleyManager/useGalleyManagerActions.js b/src/managers/GalleyManager/useGalleyManagerActions.js index affddb116..95f4de0f8 100644 --- a/src/managers/GalleyManager/useGalleyManagerActions.js +++ b/src/managers/GalleyManager/useGalleyManagerActions.js @@ -12,10 +12,10 @@ export const Actions = { export function useGalleyManagerActions() { const {t} = useLocalize(); - function getBottomActions({canEditPublication}) { + function getBottomActions({canEdit}) { const actions = []; - if (!canEditPublication) { + if (!canEdit) { return []; } @@ -28,9 +28,9 @@ export function useGalleyManagerActions() { return actions; } - function getTopItems({canEditPublication}) { + function getTopItems({canEdit}) { const actions = []; - if (!canEditPublication) { + if (!canEdit) { return []; } @@ -39,10 +39,10 @@ export function useGalleyManagerActions() { return actions; } - function getItemActions({canEditPublication}) { + function getItemActions({canEdit}) { const actions = []; - if (!canEditPublication) { + if (!canEdit) { return [ { label: t('common.view'), diff --git a/src/managers/ReviewerManager/useReviewerManagerActions.js b/src/managers/ReviewerManager/useReviewerManagerActions.js index 628fcbfee..cc454e2df 100644 --- a/src/managers/ReviewerManager/useReviewerManagerActions.js +++ b/src/managers/ReviewerManager/useReviewerManagerActions.js @@ -326,6 +326,8 @@ export function useReviewerManagerActions() { {submission, reviewAssignment, submissionStageId}, finishedCallback, ) { + // http://localhost:8000/index.php/publicknowledge/$$$call$$$/grid/users/reviewer/reviewer-grid/edit-review?submissionId=7&reviewAssignmentId=12&stageId=3 + const {openLegacyModal} = useLegacyGridUrl({ component: 'grid.users.reviewer.ReviewerGridHandler', diff --git a/src/pages/workflow/WorkflowPage.vue b/src/pages/workflow/WorkflowPage.vue index 031e9e804..76bd1c434 100644 --- a/src/pages/workflow/WorkflowPage.vue +++ b/src/pages/workflow/WorkflowPage.vue @@ -19,7 +19,7 @@ diff --git a/src/pages/workflow/WorkflowPageOJS.vue b/src/pages/workflow/WorkflowPageOJS.vue new file mode 100644 index 000000000..35ff57089 --- /dev/null +++ b/src/pages/workflow/WorkflowPageOJS.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/pages/workflow/composables/useWorkflowActions.js b/src/pages/workflow/composables/useWorkflowActions.js index 5eefd937d..72b7a3ae0 100644 --- a/src/pages/workflow/composables/useWorkflowActions.js +++ b/src/pages/workflow/composables/useWorkflowActions.js @@ -311,13 +311,13 @@ export function useWorkflowActions({ }); } + // OMP - might be moved to separate file async function workflowChangeWorktype( {submission, workType}, finishedCallback, ) { const {apiUrl} = useUrl(`submissions/${submission.id}`); - console.log('workType:', workType); const {fetch} = useFetch(apiUrl, {method: 'PUT', body: {workType}}); await fetch(); @@ -339,6 +339,7 @@ export function useWorkflowActions({ workflowCreateNewVersion, workflowPreviewPublication, workflowChangeSubmissionLanguage, + // OMP workflowChangeWorktype, }; } diff --git a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js index 269655467..7ee8c7e4d 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/useWorkflowConfigOJS.js @@ -7,7 +7,7 @@ import * as ConfigEditorialShared from './workflowConfigEditorialOJS'; import * as ConfigAuthorOJS from './workflowConfigAuthorOJS'; import * as ConfigEditorialOJS from './workflowConfigEditorialOJS'; -export function useWorkflowConfigOMP({dashboardPage}) { +export function useWorkflowConfigOJS({dashboardPage}) { const {t} = useLocalize(); let Configs = null; @@ -82,7 +82,7 @@ export function useWorkflowConfigOMP({dashboardPage}) { itemsArgs, ) || []), ]; - } else if (selectedMenuState.publicationMenu) { + } else if (selectedMenuState.primaryMenuItem === 'publication') { const itemsArgs = { submission, pageInitConfig: pageInitConfig, @@ -97,24 +97,7 @@ export function useWorkflowConfigOMP({dashboardPage}) { return [ ...(Configs.PublicationConfig?.common?.[getterFnName]?.(itemsArgs) || []), - ...(Configs.PublicationConfig[selectedMenuState.publicationMenu]?.[ - getterFnName - ]?.(itemsArgs) || []), - ]; - } else if (selectedMenuState.marketingMenu) { - const itemsArgs = { - submission, - pageInitConfig: pageInitConfig, - permissions, - }; - - if (!submission) { - return []; - } - - return [ - ...(Configs.MarketingConfig?.common?.[getterFnName]?.(itemsArgs) || []), - ...(Configs.MarketingConfig[selectedMenuState.marketingMenu]?.[ + ...(Configs.PublicationConfig[selectedMenuState.secondaryMenuItem]?.[ getterFnName ]?.(itemsArgs) || []), ]; diff --git a/src/pages/workflow/composables/useWorkflowDataSubmissionPublication.js b/src/pages/workflow/composables/useWorkflowDataSubmissionPublication.js index 2415c8920..a6c0a89e4 100644 --- a/src/pages/workflow/composables/useWorkflowDataSubmissionPublication.js +++ b/src/pages/workflow/composables/useWorkflowDataSubmissionPublication.js @@ -18,6 +18,15 @@ export function useWorkflowDataSubmissionPublication({submissionId}) { if (selectedPublicationId.value !== publicationId) { selectedPublicationId.value = publicationId; selectedPublication.value = null; + + const isPublicationInSubmission = submission.value?.publications?.find( + (publication) => publication.id === publicationId, + ); + + if (!isPublicationInSubmission) { + submission.value = null; + fetchSubmission(); + } fetchSelectedPublication(); } } diff --git a/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigation.js b/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigation.js deleted file mode 100644 index a97935880..000000000 --- a/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigation.js +++ /dev/null @@ -1,4 +0,0 @@ -export function useWorkflowNavigation({ - getMenuItems, - getInitialSelectionItemKey, -}) {} diff --git a/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOJS.js b/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOJS.js index 5245b4183..69b08bac1 100644 --- a/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOJS.js +++ b/src/pages/workflow/composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOJS.js @@ -268,6 +268,10 @@ export function useWorkflowNavigationConfigOJS(pageInitConfig) { } function getMenuItems({submission, permissions}) { + if (!submission) { + return []; + } + const menuItems = [ { key: 'workflow', diff --git a/src/pages/workflow/workflowStoreOJS.js b/src/pages/workflow/workflowStoreOJS.js new file mode 100644 index 000000000..70a8218b8 --- /dev/null +++ b/src/pages/workflow/workflowStoreOJS.js @@ -0,0 +1,264 @@ +import {computed, watch, markRaw} from 'vue'; + +import {defineComponentStore} from '@/utils/defineComponentStore'; +import { + useWorkflowActions, + Actions as WorkflowActions, +} from './composables/useWorkflowActions'; + +import { + useWorkflowDecisions, + Actions as DecisionActions, +} from './composables/useWorkflowDecisions'; + +import {useDataChangedProvider} from '@/composables/useDataChangedProvider'; + +import {wrapActionFns} from '@/utils/wrapActionFns'; + +import {useWorkflowConfigOJS as useWorkflowConfig} from './composables/useWorkflowConfig/useWorkflowConfigOJS'; +import {useWorkflowNavigationConfigOJS as useWorkflowNavigationConfig} from './composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOJS'; + +import {useWorkflowDataSubmissionPublication} from './composables/useWorkflowDataSubmissionPublication'; +import {useWorkflowPermissions} from './composables/useWorkflowPermissions'; +import {useWorkflowMenu} from './composables/useWorkflowMenu'; +import {useWorkflowItems} from './composables/useWorkflowItems'; +import {useSubmission} from '@/composables/useSubmission'; + +import FileManager from '@/managers/FileManager/FileManager.vue'; +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 GalleyManager from '@/managers/GalleyManager/GalleyManager.vue'; +import WorkflowActionButton from './components/action/WorkflowActionButton.vue'; +import WorkflowRecommendOnlyControls from './components/action/WorkflowRecommendOnlyControls.vue'; +import WorkflowRecommendOnlyListingRecommendations from './components/secondary/WorkflowRecommendOnlyListingRecommendations.vue'; +import WorkflowNotificationDisplay from './components/primary/WorkflowNotificationDisplay.vue'; +import WorkflowPaymentDropdown from './components/header/WorkflowPaymentDropdown.vue'; +import WorkflowPublicationForm from './components/publication/WorkflowPublicationForm.vue'; +import WorkflowPublicationJats from './components/publication/WorkflowPublicationJats.vue'; +import WorkflowPublicationVersionControl from './components/publication/WorkflowPublicationVersionControl.vue'; +import WorkflowChangeSubmissionLanguage from './components/publication/WorkflowChangeSubmissionLanguage.vue'; +import WorkflowPrimaryBasicMetadata from './components/primary/WorkflowPrimaryBasicMetadata.vue'; +import WorkflowReviewRoundStatus from './components/primary/WorkflowReviewRoundStatus.vue'; +import WorkflowSubmissionStatus from './components/primary/WorkflowSubmissionStatus.vue'; +import WorkflowPublicationEditDisabled from './components/publication/WorkflowPublicationEditDisabled.vue'; + +export const useWorkflowStore = defineComponentStore('workflow', (props) => { + const dashboardPage = props.pageInitConfig.dashboardPage; + + /** + * Submission & Publication + */ + const { + submission, + submissionId, + selectPublicationId, + selectedPublication, + selectedPublicationId, + refetchSubmissionPublication, + } = useWorkflowDataSubmissionPublication({submissionId: props.submissionId}); + + const {getExtendedStage, getExtendedStageLabel} = useSubmission(); + + /** + * Current Stage Indication + */ + const extendedStage = computed( + () => submission.value && getExtendedStage(submission.value), + ); + const stageLabel = computed( + () => submission.value && getExtendedStageLabel(submission.value), + ); + + /** + * Data changes tracking + */ + const {triggerDataChange} = useDataChangedProvider(() => { + return refetchSubmissionPublication(); + }); + + /** + * UI Permissions + */ + const {permissions} = useWorkflowPermissions({ + submission, + selectedPublication, + }); + + /** + * Navigation + */ + + const {getMenuItems, getInitialSelectionItemKey} = + useWorkflowNavigationConfig(props.pageInitConfig); + + const menuItems = computed(() => + getMenuItems({ + submission: submission.value, + permissions: permissions.value, + }), + ); + + const { + menuTitle, + navigateToMenu, + selectedMenuState, + selectedReviewRound, + setExpandedKeys, + sideMenuProps, + } = useWorkflowMenu({menuItems, submission}); + + setExpandedKeys([ + 'workflow', + 'publication', + 'marketing', + `workflow_${pkp.const.WORKFLOW_STAGE_ID_EXTERNAL_REVIEW}`, + ]); + + /** When submission is loaded initially - select relevant menu */ + watch(submission, (newSubmission, oldSubmission) => { + // Once the submission is fetched, select relevant stage in navigaton + if (!oldSubmission && newSubmission) { + console.log( + 'navigate to menu:', + getInitialSelectionItemKey(newSubmission), + ); + navigateToMenu(getInitialSelectionItemKey(newSubmission)); + } + }); + + /** + * Expose workflow actions + * + */ + const _workflowActionsFns = useWorkflowActions(props.pageInitConfig); + const workflowActions = wrapActionFns( + WorkflowActions, + _workflowActionsFns, + (actionFn, actionArgs, finishedCallback = null) => + actionFn( + { + ...actionArgs, + submission: submission.value, + selectedPublication: selectedPublication.value, + reviewRoundId: selectedReviewRound.value?.id, + store, + }, + (finishedData) => { + triggerDataChange(); + if (finishedCallback) { + finishedCallback(finishedData); + } + }, + ), + ); + + /** + * Expose decision functions + * + * */ + const _workflowDecisionsFns = useWorkflowDecisions(); + const decisionActions = wrapActionFns( + DecisionActions, + _workflowDecisionsFns, + (actionFn, actionArgs) => + actionFn({ + ...actionArgs, + submission: submission.value, + selectedPublication: selectedPublication.value, + reviewRoundId: selectedReviewRound.value?.id, + }), + ); + + /** + * Items + * + * */ + + const _workflowConfigFns = useWorkflowConfig({dashboardPage}); + + const { + headerItems, + primaryItems, + secondaryItems, + actionItems, + publicationControlsLeft, + publicationControlsRight, + } = useWorkflowItems(_workflowConfigFns, () => ({ + selectedMenuState: selectedMenuState.value, + submission: submission.value, + pageInitConfig: props.pageInitConfig, + selectedPublication: selectedPublication.value, + selectedPublicationId: selectedPublicationId.value, + selectedReviewRound: selectedReviewRound.value, + permissions: permissions.value, + publicationSettings: props.pageInitConfig.publicationSettings, + })); + + const Components = markRaw({ + FileManager, + ReviewerManager, + DiscussionManager, + ContributorManager, + ParticipantManager, + GalleyManager, + WorkflowActionButton, + WorkflowRecommendOnlyControls, + WorkflowRecommendOnlyListingRecommendations, + WorkflowNotificationDisplay, + WorkflowPaymentDropdown, + WorkflowPrimaryBasicMetadata, + WorkflowReviewRoundStatus, + WorkflowPublicationForm, + WorkflowPublicationJats, + WorkflowPublicationVersionControl, + WorkflowChangeSubmissionLanguage, + WorkflowSubmissionStatus, + WorkflowPublicationEditDisabled, + }); + + const store = { + dashboardPage, + submission, + submissionId, + selectedPublication, + selectPublicationId, + extendedStage, + stageLabel, + + /** + * Navigation + * */ + sideMenuProps, + selectedMenuState, + navigateToMenu, + + /** Actions + * + */ + ...workflowActions, + ...decisionActions, + + /** + * Summary + */ + menuTitle, + headerItems, + primaryItems, + secondaryItems, + actionItems, + publicationControlsLeft, + publicationControlsRight, + + /** + * Expose for extensions + */ + + _workflowActionsFns, + _workflowDecisionsFns, + + Components, + }; + return store; +}); diff --git a/src/pages/workflow/workflowStoreOMP.js b/src/pages/workflow/workflowStoreOMP.js index 63f356459..cb87d90fe 100644 --- a/src/pages/workflow/workflowStoreOMP.js +++ b/src/pages/workflow/workflowStoreOMP.js @@ -15,7 +15,6 @@ import {useDataChangedProvider} from '@/composables/useDataChangedProvider'; import {wrapActionFns} from '@/utils/wrapActionFns'; -// #else import {useWorkflowConfigOMP as useWorkflowConfig} from './composables/useWorkflowConfig/useWorkflowConfigOMP'; import {useWorkflowNavigationConfigOMP as useWorkflowNavigationConfig} from './composables/useWorkflowNavigationConfig/useWorkflowNavigationConfigOMP'; @@ -40,9 +39,7 @@ import WorkflowActionButton from './components/action/WorkflowActionButton.vue'; import WorkflowRecommendOnlyControls from './components/action/WorkflowRecommendOnlyControls.vue'; import WorkflowRecommendOnlyListingRecommendations from './components/secondary/WorkflowRecommendOnlyListingRecommendations.vue'; import WorkflowNotificationDisplay from './components/primary/WorkflowNotificationDisplay.vue'; -import WorkflowPaymentDropdown from './components/header/WorkflowPaymentDropdown.vue'; import WorkflowPublicationForm from './components/publication/WorkflowPublicationForm.vue'; -import WorkflowPublicationJats from './components/publication/WorkflowPublicationJats.vue'; import WorkflowPublicationVersionControl from './components/publication/WorkflowPublicationVersionControl.vue'; import WorkflowChangeSubmissionLanguage from './components/publication/WorkflowChangeSubmissionLanguage.vue'; import WorkflowPrimaryBasicMetadata from './components/primary/WorkflowPrimaryBasicMetadata.vue'; @@ -216,11 +213,9 @@ export const useWorkflowStore = defineComponentStore('workflow', (props) => { WorkflowRecommendOnlyControls, WorkflowRecommendOnlyListingRecommendations, WorkflowNotificationDisplay, - WorkflowPaymentDropdown, WorkflowPrimaryBasicMetadata, WorkflowReviewRoundStatus, WorkflowPublicationForm, - WorkflowPublicationJats, WorkflowPublicationVersionControl, WorkflowChangeSubmissionLanguage, WorkflowSubmissionStatus,