add option to remove all drafts in one go
This commit is contained in:
parent
17b82be1a4
commit
5cb0204305
3 changed files with 76 additions and 21 deletions
|
|
@ -1,16 +1,39 @@
|
||||||
import Draft from 'src/components/draft/draft.vue'
|
import Draft from 'src/components/draft/draft.vue'
|
||||||
import List from 'src/components/list/list.vue'
|
import List from 'src/components/list/list.vue'
|
||||||
|
import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue'
|
||||||
|
|
||||||
const Drafts = {
|
const Drafts = {
|
||||||
components: {
|
components: {
|
||||||
Draft,
|
Draft,
|
||||||
List,
|
List,
|
||||||
|
ConfirmModal,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showingConfirmDialog: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
drafts() {
|
drafts() {
|
||||||
return this.$store.getters.draftsArray
|
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
|
export default Drafts
|
||||||
|
|
|
||||||
|
|
@ -13,36 +13,66 @@
|
||||||
>
|
>
|
||||||
{{ $t('drafts.no_drafts') }}
|
{{ $t('drafts.no_drafts') }}
|
||||||
</div>
|
</div>
|
||||||
<List
|
<template v-else>
|
||||||
v-else
|
<List
|
||||||
:items="drafts"
|
:items="drafts"
|
||||||
:non-interactive="true"
|
:non-interactive="true"
|
||||||
>
|
>
|
||||||
<template #item="{ item: draft }">
|
<template #item="{ item: draft }">
|
||||||
<Draft
|
<Draft
|
||||||
class="draft"
|
class="draft"
|
||||||
:draft="draft"
|
:draft="draft"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</List>
|
</List>
|
||||||
|
<div class="remove-all">
|
||||||
|
<button
|
||||||
|
class="btn -danger button-default"
|
||||||
|
@click="abandonAll"
|
||||||
|
>
|
||||||
|
{{ $t('drafts.clean_drafts') }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<teleport to="#modal">
|
||||||
|
<confirm-modal
|
||||||
|
v-if="showingConfirmDialog"
|
||||||
|
:confirm-danger="true"
|
||||||
|
:title="$t('drafts.abandon_confirm_title')"
|
||||||
|
:confirm-text="$t('drafts.abandon_confirm_accept_button')"
|
||||||
|
:cancel-text="$t('drafts.abandon_confirm_cancel_button')"
|
||||||
|
@accepted="doAbandonAll"
|
||||||
|
@cancelled="hideConfirmDialog"
|
||||||
|
>
|
||||||
|
{{ $t('drafts.abandon_all_confirm') }}
|
||||||
|
</confirm-modal>
|
||||||
|
</teleport>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./drafts.js"></script>
|
<script src="./drafts.js"></script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.draft {
|
.Drafts {
|
||||||
margin: 1em 0;
|
.draft {
|
||||||
}
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
.empty-drafs-list-alert {
|
.remove-all {
|
||||||
padding: 3em;
|
margin: 1em;
|
||||||
font-size: 1.2em;
|
display: flex;
|
||||||
display: flex;
|
justify-content: center;
|
||||||
justify-content: center;
|
}
|
||||||
color: var(--textFaint);
|
|
||||||
|
.empty-drafs-list-alert {
|
||||||
|
padding: 3em;
|
||||||
|
font-size: 1.2em;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--textFaint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1884,6 +1884,7 @@
|
||||||
"drafts": {
|
"drafts": {
|
||||||
"drafts": "Drafts",
|
"drafts": "Drafts",
|
||||||
"no_drafts": "You have no drafts",
|
"no_drafts": "You have no drafts",
|
||||||
|
"clean_drafts": "Remove all drafts",
|
||||||
"empty": "(No content)",
|
"empty": "(No content)",
|
||||||
"poll_tooltip": "Draft contains a poll",
|
"poll_tooltip": "Draft contains a poll",
|
||||||
"continue": "Continue composing",
|
"continue": "Continue composing",
|
||||||
|
|
@ -1893,6 +1894,7 @@
|
||||||
"abandon_confirm": "Do you really want to abandon this draft?",
|
"abandon_confirm": "Do you really want to abandon this draft?",
|
||||||
"abandon_confirm_accept_button": "Abandon",
|
"abandon_confirm_accept_button": "Abandon",
|
||||||
"abandon_confirm_cancel_button": "Keep",
|
"abandon_confirm_cancel_button": "Keep",
|
||||||
|
"abandon_all_confirm": "Do you really want to abandon all drafts?",
|
||||||
"replying": "Replying to {statusLink}",
|
"replying": "Replying to {statusLink}",
|
||||||
"editing": "Editing {statusLink}",
|
"editing": "Editing {statusLink}",
|
||||||
"unavailable": "(unavailable)"
|
"unavailable": "(unavailable)"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue