diff --git a/src/components/drafts/drafts.js b/src/components/drafts/drafts.js index 8acde3c17..0fdd962fc 100644 --- a/src/components/drafts/drafts.js +++ b/src/components/drafts/drafts.js @@ -1,16 +1,39 @@ import Draft from 'src/components/draft/draft.vue' import List from 'src/components/list/list.vue' +import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue' const Drafts = { components: { Draft, List, + ConfirmModal, + }, + data() { + return { + showingConfirmDialog: false + } }, computed: { drafts() { return this.$store.getters.draftsArray }, }, + methods: { + abandonAll() { + this.showingConfirmDialog = true + }, + doAbandonAll() { + this.drafts.forEach((draft) => { + this.$store.dispatch('abandonDraft', { id: draft.id }).then(() => { + this.hideConfirmDialog() + }) + }) + this.hideConfirmDialog() + }, + hideConfirmDialog() { + this.showingConfirmDialog = false + }, + } } export default Drafts diff --git a/src/components/drafts/drafts.vue b/src/components/drafts/drafts.vue index 1cce255da..3a22969e1 100644 --- a/src/components/drafts/drafts.vue +++ b/src/components/drafts/drafts.vue @@ -13,36 +13,66 @@ > {{ $t('drafts.no_drafts') }} - - - - - + + + + + + + + + {{ $t('drafts.clean_drafts') }} + + + + + + {{ $t('drafts.abandon_all_confirm') }} + + diff --git a/src/i18n/en.json b/src/i18n/en.json index 9eae42456..b15f4dbe9 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1884,6 +1884,7 @@ "drafts": { "drafts": "Drafts", "no_drafts": "You have no drafts", + "clean_drafts": "Remove all drafts", "empty": "(No content)", "poll_tooltip": "Draft contains a poll", "continue": "Continue composing", @@ -1893,6 +1894,7 @@ "abandon_confirm": "Do you really want to abandon this draft?", "abandon_confirm_accept_button": "Abandon", "abandon_confirm_cancel_button": "Keep", + "abandon_all_confirm": "Do you really want to abandon all drafts?", "replying": "Replying to {statusLink}", "editing": "Editing {statusLink}", "unavailable": "(unavailable)"