Skip to content

Commit

Permalink
pkp/pkp-lib#7495 OPS navigaton config clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec committed Nov 7, 2024
1 parent bcafd3b commit a0ab8c6
Showing 1 changed file with 4 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
import {useSubmission} from '@/composables/useSubmission';
import {useLocalize} from '@/composables/useLocalize';
import {DashboardPageTypes} from '@/pages/dashboard/dashboardPageStore';
import {
getPublicationItem,
getWorkflowItem,
} from './useWorkflowNavigationConfigOJS';

const {t} = useLocalize();

const StageColors = {
[pkp.const.WORKFLOW_STAGE_ID_SUBMISSION]: 'border-stage-desk-review',
[pkp.const.WORKFLOW_STAGE_ID_EXTERNAL_REVIEW]: 'border-stage-in-review',
[pkp.const.WORKFLOW_STAGE_ID_EDITING]: 'border-stage-copyediting',
[pkp.const.WORKFLOW_STAGE_ID_PRODUCTION]: 'border-stage-production',
};

export function getPublicationItem({label, name}) {
return {
key: `publication_${name}`,
label: label,
action: 'selectMenu',
actionArgs: {
primaryMenuItem: 'publication',
secondaryMenuItem: name,
title: getPublicationTitle(label),
},
};
}

export function getWorkflowItem({stageId, label, isActive, isDisabled, items}) {
return {
key: `workflow_${stageId}`,
label: label,
colorStripe: isActive ? StageColors[stageId] : null,
action: isDisabled ? undefined : 'selectMenu',
actionArgs: {
primaryMenuItem: 'workflow',
stageId: stageId,
title: getWorkflowTitle(label),
},
items,
};
}

export function getWorkflowTitle(stageLabel) {
return `${t('semicolon', {label: t('manager.workflow')})} ${stageLabel} `;
}
Expand All @@ -49,48 +18,6 @@ export function getPublicationTitle(publicationMenuTitle) {
})} ${publicationMenuTitle}`;
}

export function getReviewItems({submission, stageId, title}) {
const {getActiveStage, getCurrentReviewRound} = useSubmission();

const activeStage = getActiveStage(submission);

const activeReviewRound = getCurrentReviewRound(submission, stageId);

const reviewMenuItems = [];

const {getReviewRoundsForStage} = useSubmission();
const reviewRounds = getReviewRoundsForStage(submission, stageId);

reviewRounds.forEach((reviewRound) => {
reviewMenuItems.push(
getReviewItem({
stageId,
reviewRound,
isActive:
activeStage.id === stageId && activeReviewRound.id === reviewRound.id,
title: title,
}),
);
});

return reviewMenuItems;
}

export function getReviewItem({stageId, reviewRound, isActive, title}) {
return {
key: `workflow_${stageId}_${reviewRound.id}`,
label: t('dashboard.workflow.reviewRoundN', {number: reviewRound.round}),
colorStripe: isActive ? StageColors[stageId] : null,
action: 'selectMenu',
actionArgs: {
primaryMenuItem: 'workflow',
stageId: stageId,
reviewRoundId: reviewRound.id,
title: title,
},
};
}

export function useWorkflowNavigationConfigOPS(pageInitConfig) {
const {publicationSettings} = pageInitConfig;
const {t} = useLocalize();
Expand Down

0 comments on commit a0ab8c6

Please sign in to comment.