diff --git a/src/components/Container/Page.vue b/src/components/Container/Page.vue index 803ca8658..df503d541 100644 --- a/src/components/Container/Page.vue +++ b/src/components/Container/Page.vue @@ -45,51 +45,7 @@ export default { unreadTasksCount: 0, }; }, - computed: { - /** - * The menu item entry for a back-to-dashboard link - * - * @return {Object|null} - */ - backToDashboardLink() { - if (this.useBackToDashboard) { - return this.menu[Object.keys(this.menu)[0]]; - } - return null; - }, - - /** - * The new label for the back-to-dashboard link - * - * Converts "Submissions" to "Back to Submissions" - * - * @return {String} - */ - backToDashboardLabel() { - if (this.backToDashboardLink) { - return this.t('navigation.backTo', { - page: this.backToDashboardLink.name, - }); - } - return null; - }, - - /** - * Should a back-to-dashboard link be shown instead of a - * full navigation menu? - * - * This is the case when the nav menu contains only one link. - * - * @return {Boolean} - */ - useBackToDashboard() { - return ( - !!this.menu && - Object.keys(this.menu).length === 1 && - !this.menu[Object.keys(this.menu)[0]].isCurrent - ); - }, - }, + computed: {}, mounted() { /** * Fire a callback when the URL #hash is changed 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', + }); + } }, }; diff --git a/src/components/DropdownActions/DropdownActions.vue b/src/components/DropdownActions/DropdownActions.vue index f25566f33..2b1737629 100644 --- a/src/components/DropdownActions/DropdownActions.vue +++ b/src/components/DropdownActions/DropdownActions.vue @@ -1,30 +1,22 @@