Make it possible to unarchive all archived cards

Signed-off-by: Eduard Stromenko <estromenko@mail.ru>
This commit is contained in:
estromenko
2021-09-16 09:55:49 +03:00
committed by Julius Härtl
parent 7c8e762d5d
commit 6ed7f672fc

View File

@@ -43,9 +43,12 @@
</form> </form>
</transition> </transition>
<Actions v-if="canManage && !isArchived" :force-menu="true"> <Actions v-if="canManage && !isArchived" :force-menu="true">
<ActionButton icon="icon-archive" @click="modalArchivAllCardsShow=true"> <ActionButton v-if="!showArchived" icon="icon-archive" @click="modalArchivAllCardsShow=true">
{{ t('deck', 'Archive all cards') }} {{ t('deck', 'Archive all cards') }}
</ActionButton> </ActionButton>
<ActionButton v-if="showArchived" icon="icon-archive" @click="modalArchivAllCardsShow=true">
{{ t('deck', 'Unarchive all cards') }}
</ActionButton>
<ActionButton icon="icon-delete" @click="deleteStack(stack)"> <ActionButton icon="icon-delete" @click="deleteStack(stack)">
{{ t('deck', 'Delete list') }} {{ t('deck', 'Delete list') }}
</ActionButton> </ActionButton>
@@ -59,11 +62,20 @@
<Modal v-if="modalArchivAllCardsShow" @close="modalArchivAllCardsShow=false"> <Modal v-if="modalArchivAllCardsShow" @close="modalArchivAllCardsShow=false">
<div class="modal__content"> <div class="modal__content">
<h3>{{ t('deck', 'Archive all cards in this list') }}</h3> <h3 v-if="!showArchived">
{{ t('deck', 'Archive all cards in this list') }}
</h3>
<h3 v-else>
{{ t('deck', 'Unarchive all cards in this list') }}
</h3>
<progress :value="stackTransfer.current" :max="stackTransfer.total" /> <progress :value="stackTransfer.current" :max="stackTransfer.total" />
<button class="primary" @click="archiveAllCardsFromStack(stack)"> <button v-if="!showArchived" class="primary" @click="setArchivedToAllCardsFromStack(stack, !showArchived)">
{{ t('deck', 'Archive all cards') }} {{ t('deck', 'Archive all cards') }}
</button> </button>
<button v-else class="primary" @click="setArchivedToAllCardsFromStack(stack, !showArchived)">
{{ t('deck', 'Unarchive all cards') }}
</button>
<button @click="modalArchivAllCardsShow=false"> <button @click="modalArchivAllCardsShow=false">
{{ t('deck', 'Cancel') }} {{ t('deck', 'Cancel') }}
</button> </button>
@@ -222,12 +234,12 @@ export default {
this.$store.dispatch('deleteStack', stack) this.$store.dispatch('deleteStack', stack)
showUndo(t('deck', 'List deleted'), () => this.$store.dispatch('stackUndoDelete', stack)) showUndo(t('deck', 'List deleted'), () => this.$store.dispatch('stackUndoDelete', stack))
}, },
archiveAllCardsFromStack(stack) { setArchivedToAllCardsFromStack(stack, isArchived) {
this.stackTransfer.total = this.cardsByStack.length this.stackTransfer.total = this.cardsByStack.length
this.cardsByStack.forEach((card, index) => { this.cardsByStack.forEach((card, index) => {
this.stackTransfer.current = index this.stackTransfer.current = index
this.$store.dispatch('archiveUnarchiveCard', { ...card, archived: true }) this.$store.dispatch('archiveUnarchiveCard', { ...card, archived: isArchived })
}) })
this.modalArchivAllCardsShow = false this.modalArchivAllCardsShow = false
}, },