Skip to content

Commit

Permalink
pkp/pkp-lib#10599 Add delete button for editors for declined submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec committed Dec 5, 2024
1 parent cbee742 commit b687261
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 13 deletions.
30 changes: 30 additions & 0 deletions src/pages/workflow/composables/useWorkflowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const Actions = {
WORKFLOW_UNPUBLISH_PUBLICATION: 'workflowUnpublishPublication',
WORKFLOW_CREATE_NEW_VERSION: 'workflowCreateNewVersion',
WORKFLOW_CHANGE_SUBMISSION_LANGUAGE: 'workflowChangeSubmissionLanguage',
WORKFLOW_DELETE_SUBMISSION: 'workflowDeleteSubmission',

// OMP
WORKFLOW_CHANGE_WORKTYPE: 'workflowChangeWorktype',
Expand Down Expand Up @@ -314,6 +315,34 @@ export function useWorkflowActions({
});
}

function workflowDeleteSubmission({submission, store}) {
const {apiUrl} = useUrl(`_submissions/${submission.id}`);
const {fetch: fetchDelete} = useFetch(apiUrl, {method: 'DELETE'});
const {openDialog} = useModal();

openDialog({
title: t('common.delete'),
message: t('editor.submissionArchive.confirmDelete'),
actions: [
{
label: t('common.confirm'),
isPrimary: true,
callback: async (close) => {
await fetchDelete();
close();
store.closeWorkflowModal();
},
},
{
label: t('common.cancel'),
isWarnable: true,
callback: (close) => close(),
},
],
modalStyle: 'negative',
});
}

// OMP - might be moved to separate file
async function workflowChangeWorktype(
{submission, workType},
Expand Down Expand Up @@ -342,6 +371,7 @@ export function useWorkflowActions({
workflowCreateNewVersion,
workflowPreviewPublication,
workflowChangeSubmissionLanguage,
workflowDeleteSubmission,
// OMP
workflowChangeWorktype,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {useLocalize} from '@/composables/useLocalize';
import {Actions} from '../useWorkflowActions';
import {useSubmission} from '@/composables/useSubmission';
import {useCurrentUser} from '@/composables/useCurrentUser';

import {Actions as WorkflowActions} from '../useWorkflowActions';
import {Actions as DecisionActions} from '../useWorkflowDecisions';
import {addItemIf} from './workflowConfigHelpers';
Expand All @@ -11,6 +13,9 @@ const {
isDecisionAvailable,
hasNotSubmissionStartedStage,
} = useSubmission();

const {hasCurrentUserAtLeastOneAssignedRoleInAnyStage} = useCurrentUser();

const {t} = useLocalize();

export function getHeaderItems({
Expand Down Expand Up @@ -208,6 +213,27 @@ export const WorkflowConfig = {
),
);

// Delete submission
addItemIf(
items,
{
component: 'WorkflowActionButton',
props: {
label: t('common.delete'),
isWarnable: true,
action: WorkflowActions.WORKFLOW_DELETE_SUBMISSION,
},
},
isDecisionAvailable(
submission,
pkp.const.DECISION_REVERT_INITIAL_DECLINE,
) &&
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SITE_ADMIN,
]),
);

return items;
},
},
Expand Down Expand Up @@ -410,6 +436,24 @@ export const WorkflowConfig = {
},
isDecisionAvailable(submission, pkp.const.DECISION_REVERT_DECLINE),
);

// Delete submission
addItemIf(
items,
{
component: 'WorkflowActionButton',
props: {
label: t('common.delete'),
isWarnable: true,
action: WorkflowActions.WORKFLOW_DELETE_SUBMISSION,
},
},
isDecisionAvailable(submission, pkp.const.DECISION_REVERT_DECLINE) &&
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SITE_ADMIN,
]),
);
}
return items;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import {useLocalize} from '@/composables/useLocalize';
import {Actions} from '../useWorkflowActions';
import {Actions as WorkflowActions} from '../useWorkflowActions';
import {useSubmission} from '@/composables/useSubmission';
import {useCurrentUser} from '@/composables/useCurrentUser';

import {Actions as DecisionActions} from '../useWorkflowDecisions';
import {addItemIf} from './workflowConfigHelpers';
const {hasSubmissionPassedStage, getStageById, isDecisionAvailable} =
useSubmission();
const {hasCurrentUserAtLeastOneAssignedRoleInAnyStage} = useCurrentUser();

const {t} = useLocalize();

export function getHeaderItems({
Expand All @@ -31,7 +35,7 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('common.view'),
action: Actions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
},
});
}
Expand All @@ -41,15 +45,15 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('editor.activityLog'),
action: Actions.WORKFLOW_VIEW_ACTIVITY_LOG,
action: WorkflowActions.WORKFLOW_VIEW_ACTIVITY_LOG,
},
});
}
items.push({
component: 'WorkflowActionButton',
props: {
label: t('editor.submissionLibrary'),
action: Actions.WORKFLOW_VIEW_LIBRARY,
action: WorkflowActions.WORKFLOW_VIEW_LIBRARY,
},
});

Expand Down Expand Up @@ -121,6 +125,26 @@ export const WorkflowConfig = {
),
);

addItemIf(
items,
{
component: 'WorkflowActionButton',
props: {
label: t('common.delete'),
isWarnable: true,
action: WorkflowActions.WORKFLOW_DELETE_SUBMISSION,
},
},
isDecisionAvailable(
submission,
pkp.const.DECISION_REVERT_INITIAL_DECLINE,
) &&
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SITE_ADMIN,
]),
);

addItemIf(
items,
{
Expand Down Expand Up @@ -349,6 +373,26 @@ export const WorkflowConfig = {
pkp.const.DECISION_REVERT_INTERNAL_DECLINE,
),
);

addItemIf(
items,
{
component: 'WorkflowActionButton',
props: {
label: t('common.delete'),
isWarnable: true,
action: WorkflowActions.WORKFLOW_DELETE_SUBMISSION,
},
},
isDecisionAvailable(
submission,
pkp.const.DECISION_REVERT_INTERNAL_DECLINE,
) &&
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SITE_ADMIN,
]),
);
}
return items;
},
Expand Down Expand Up @@ -422,7 +466,7 @@ export const PublicationConfig = {
props: {
label: t('common.preview'),
isSecondary: true,
action: Actions.WORKFLOW_PREVIEW_PUBLICATION,
action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION,
},
});
}
Expand All @@ -434,7 +478,7 @@ export const PublicationConfig = {

label: t('publication.publish'),
isSecondary: true,
action: Actions.WORKFLOW_SCHEDULE_FOR_PUBLICATION,
action: WorkflowActions.WORKFLOW_SCHEDULE_FOR_PUBLICATION,
},
});
} else if (selectedPublication.status === pkp.const.STATUS_SCHEDULED) {
Expand All @@ -443,7 +487,7 @@ export const PublicationConfig = {
props: {
label: t('dashboard.summary.preview'),
isSecondary: true,
action: Actions.WORKFLOW_PREVIEW_PUBLICATION,
action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION,
},
});

Expand All @@ -452,7 +496,7 @@ export const PublicationConfig = {
props: {
label: t('publication.unschedule'),
isWarnable: true,
action: Actions.WORKFLOW_UNSCHEDULE_PUBLICATION,
action: WorkflowActions.WORKFLOW_UNSCHEDULE_PUBLICATION,
},
});
} else if (selectedPublication.status === pkp.const.STATUS_PUBLISHED) {
Expand All @@ -461,7 +505,7 @@ export const PublicationConfig = {
props: {
label: t('publication.unpublish'),
isWarnable: true,
action: Actions.WORKFLOW_UNPUBLISH_PUBLICATION,
action: WorkflowActions.WORKFLOW_UNPUBLISH_PUBLICATION,
},
});

Expand All @@ -474,7 +518,7 @@ export const PublicationConfig = {
props: {
label: t('publication.createVersion'),
isSecondary: true,
action: Actions.WORKFLOW_CREATE_NEW_VERSION,
action: WorkflowActions.WORKFLOW_CREATE_NEW_VERSION,
},
});
}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/workflow/workflowStoreOJS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {computed, watch, markRaw} from 'vue';
import {computed, watch, markRaw, inject} from 'vue';

import {defineComponentStore} from '@/utils/defineComponentStore';
import {
Expand Down Expand Up @@ -47,6 +47,11 @@ import WorkflowPublicationEditDisabled from './components/publication/WorkflowPu
export const useWorkflowStore = defineComponentStore('workflow', (props) => {
const dashboardPage = props.pageInitConfig.dashboardPage;

/**
* Action to close the workflow from inside
* */
const closeWorkflowModal = inject('closeModal');

/**
* Submission & Publication
*/
Expand Down Expand Up @@ -216,6 +221,8 @@ export const useWorkflowStore = defineComponentStore('workflow', (props) => {

const store = {
dashboardPage,
closeWorkflowModal,

submission,
submissionId,
selectedPublication,
Expand Down
9 changes: 8 additions & 1 deletion src/pages/workflow/workflowStoreOMP.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {computed, watch, markRaw} from 'vue';
import {computed, watch, markRaw, inject} from 'vue';

import {defineComponentStore} from '@/utils/defineComponentStore';
import {
Expand Down Expand Up @@ -50,6 +50,11 @@ import WorkflowPublicationEditDisabled from './components/publication/WorkflowPu
export const useWorkflowStore = defineComponentStore('workflow', (props) => {
const dashboardPage = props.pageInitConfig.dashboardPage;

/**
* Action to close the workflow from inside
* */
const closeWorkflowModal = inject('closeModal');

/**
* Submission & Publication
*/
Expand Down Expand Up @@ -222,6 +227,8 @@ export const useWorkflowStore = defineComponentStore('workflow', (props) => {

const store = {
dashboardPage,
closeWorkflowModal,

submission,
submissionId,
selectedPublication,
Expand Down
9 changes: 8 additions & 1 deletion src/pages/workflow/workflowStoreOPS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {computed, watch, markRaw} from 'vue';
import {computed, watch, markRaw, inject} from 'vue';

import {defineComponentStore} from '@/utils/defineComponentStore';
import {
Expand Down Expand Up @@ -44,6 +44,11 @@ import WorkflowPublicationEditDisabled from './components/publication/WorkflowPu
export const useWorkflowStore = defineComponentStore('workflow', (props) => {
const dashboardPage = props.pageInitConfig.dashboardPage;

/**
* Action to close the workflow from inside
* */
const closeWorkflowModal = inject('closeModal');

/**
* Submission & Publication
*/
Expand Down Expand Up @@ -205,6 +210,8 @@ export const useWorkflowStore = defineComponentStore('workflow', (props) => {

const store = {
dashboardPage,
closeWorkflowModal,

submission,
submissionId,
selectedPublication,
Expand Down

0 comments on commit b687261

Please sign in to comment.