From f0809895238faabccfad8f82c00058e4454ec220 Mon Sep 17 00:00:00 2001 From: Taslan Graham Date: Thu, 9 Jan 2025 15:28:04 -0500 Subject: [PATCH] pkp/pkp-lib#8350 Allow author to cancel submission --- .../Container/SubmissionWizardPage.vue | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/components/Container/SubmissionWizardPage.vue b/src/components/Container/SubmissionWizardPage.vue index 7c9c71872..fa8c02847 100644 --- a/src/components/Container/SubmissionWizardPage.vue +++ b/src/components/Container/SubmissionWizardPage.vue @@ -90,6 +90,10 @@ export default { i18nUnsavedChanges: '', /** **Required** A localized string for the message of the dialog that appears when unsaved changes are found in local storage. */ i18nUnsavedChangesMessage: '', + /** The URL to the REST API endpoint to cancel this submission. */ + submissionCancelApiUrl: '', + /** The URL to the page to display after a submission is cancelled. */ + submissionCancelledUrl: '', }; }, computed: { @@ -782,6 +786,52 @@ export default { }); }, 500); }, + + /** + * Cancel a submission. + */ + cancelSubmission(){ + this.openDialog({ + name: 'SubmissionCancel', + title: this.t('submission.wizard.submissionCancel'), + message: this.t('submission.wizard.cancel.confirmation'), + actions: [ + { + label: this.t('common.ok'), + isPrimary: true, + callback: (close) => { + $.ajax({ + url: this.submissionCancelApiUrl, + context: this, + method: 'POST', + headers: { + 'X-Csrf-Token': pkp.currentUser.csrfToken, + 'X-Http-Method-Override': 'DELETE', + }, + error(r) { + close(); + + if (!r.responseJSON) { + this.ajaxErrorCallback({}); + } else { + this.errors = r.responseJSON; + } + }, + success() { + window.location = this.submissionCancelledUrl; + }, + }); + }, + }, + { + label: this.t('common.cancel'), + isWarnable: true, + callback: (close) => close(), + }, + ], + modalStyle: 'negative', + }); + } }, };