From 01cd1b5bbf773676b2431772057612db9f3a01bb Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Wed, 3 May 2023 17:49:34 +0100 Subject: [PATCH] pkp/pkp-lib#8880 Add assign editors button to submission lists --- src/components/Container/SubmissionsPage.vue | 46 +++++++++++++++++++ .../previews/PreviewSubmissionsPage.vue | 25 +++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/src/components/Container/SubmissionsPage.vue b/src/components/Container/SubmissionsPage.vue index 20d406885..9f96c9885 100644 --- a/src/components/Container/SubmissionsPage.vue +++ b/src/components/Container/SubmissionsPage.vue @@ -53,6 +53,7 @@ export default { return { activeFilters: {}, apiUrl: '', + assignParticipantUrl: '', count: 30, currentViewId: '', filtersForm: {}, @@ -91,6 +92,15 @@ export default { return this.views.find((view) => view.id === this.currentViewId); }, + /** + * Whether the current user is a manager (or admin) + */ + isManager() { + const roles = [pkp.const.ROLE_ID_MANAGER, pkp.const.ROLE_ID_SITE_ADMIN]; + + return !!pkp.currentUser.roles.find((role) => roles.includes(role)); + }, + /** * The number of pages available * @@ -196,6 +206,42 @@ export default { }); }, + /** + * Whether or not a submission needs an editor to be assigned + */ + needsEditors(submission) { + return !!submission.stages.find( + (stage) => + stage.id === pkp.const.WORKFLOW_STAGE_ID_SUBMISSION && + !!stage.statusId && + stage.statusId === pkp.const.STAGE_STATUS_SUBMISSION_UNASSIGNED + ); + }, + + /** + * Load a modal displaying the assign participant options + */ + openAssignParticipant(submission) { + lastFocusedEl = document.activeElement; + + var opts = { + title: this.__('submission.list.assignEditor'), + url: this.assignParticipantUrl + .replace('__id__', submission.id) + .replace('__stageId__', submission.stageId), + closeCallback: () => { + this.resetFocusToList(); + }, + }; + + $( + '
' + ).pkpHandler('$.pkp.controllers.modal.AjaxModalHandler', opts); + }, + /** * Open the panel to select filters */ diff --git a/src/docs/components/SubmissionsPage/previews/PreviewSubmissionsPage.vue b/src/docs/components/SubmissionsPage/previews/PreviewSubmissionsPage.vue index 0b9118df7..64788f613 100644 --- a/src/docs/components/SubmissionsPage/previews/PreviewSubmissionsPage.vue +++ b/src/docs/components/SubmissionsPage/previews/PreviewSubmissionsPage.vue @@ -107,7 +107,15 @@ {{ submission.daysInStage }} - TODO + + + Assign Editors + + + import SubmissionsPage from '../../../../components/Container/SubmissionsPage.vue'; +import dialog from '../../../../mixins/dialog'; import submissions from '../../../data/submissions'; import form from '../../Form/helpers/form-base'; export default { extends: SubmissionsPage, + mixins: [dialog], data() { return { count: 10, @@ -304,7 +314,7 @@ export default { }, methods: { /** - * Get submissions matching the current request params + * Override the get method to fake a request * * @param {Function} cb A callback function to fire when successful */ @@ -321,6 +331,17 @@ export default { } }, 1000); }, + + /** + * Override the request to open a modal to assign a participant + */ + openAssignParticipant(submission) { + this.openDialog({ + name: 'assignParticipant', + title: 'Assign Editor', + message: '...', + }); + }, }, };