feat: show the number of tasks we're about to remove when deleting a list
This commit is contained in:
parent
202f6ce1b2
commit
62adf171ec
4 changed files with 67 additions and 31 deletions
|
@ -2,12 +2,17 @@
|
||||||
<div class="loader-container is-loading"></div>
|
<div class="loader-container is-loading"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.loader-container {
|
.loader-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 600px;
|
min-width: 600px;
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
|
|
||||||
|
&.is-loading-small {
|
||||||
|
min-height: 50px;
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -201,7 +201,9 @@
|
||||||
"header": "Delete this list",
|
"header": "Delete this list",
|
||||||
"text1": "Are you sure you want to delete this list and all of its contents?",
|
"text1": "Are you sure you want to delete this list and all of its contents?",
|
||||||
"text2": "This includes all tasks and CANNOT BE UNDONE!",
|
"text2": "This includes all tasks and CANNOT BE UNDONE!",
|
||||||
"success": "The list was successfully deleted."
|
"success": "The list was successfully deleted.",
|
||||||
|
"tasksToDelete": "This will irrevocably remove approx. {count} tasks.",
|
||||||
|
"noTasksToDelete": "This list does not contain any tasks, it should be safe to delete."
|
||||||
},
|
},
|
||||||
"duplicate": {
|
"duplicate": {
|
||||||
"title": "Duplicate this list",
|
"title": "Duplicate this list",
|
||||||
|
@ -497,7 +499,8 @@
|
||||||
"custom": "Custom",
|
"custom": "Custom",
|
||||||
"id": "ID",
|
"id": "ID",
|
||||||
"created": "Created at",
|
"created": "Created at",
|
||||||
"actions": "Actions"
|
"actions": "Actions",
|
||||||
|
"cannotBeUndone": "This cannot be undone!"
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"resetColor": "Reset Color",
|
"resetColor": "Reset Color",
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
border-width: 0.25rem;
|
border-width: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-loading-small::after {
|
&.is-loading-small {
|
||||||
|
&::after {
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
top: calc(50% - .75rem);
|
top: calc(50% - .75rem);
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: move to ShowTasks.vue
|
// FIXME: move to ShowTasks.vue
|
||||||
.spinner.is-loading {
|
.spinner.is-loading {
|
||||||
|
|
|
@ -6,31 +6,57 @@
|
||||||
<template #header><span>{{ $t('list.delete.header') }}</span></template>
|
<template #header><span>{{ $t('list.delete.header') }}</span></template>
|
||||||
|
|
||||||
<template #text>
|
<template #text>
|
||||||
<p>{{ $t('list.delete.text1') }}<br/>
|
<p>
|
||||||
{{ $t('list.delete.text2') }}</p>
|
{{ $t('list.delete.text1') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<strong v-if="totalTasks !== null" class="has-text-white">
|
||||||
|
{{ totalTasks > 0 ? $t('list.delete.tasksToDelete', {count: totalTasks}) : $t('list.delete.noTasksToDelete') }}
|
||||||
|
</strong>
|
||||||
|
<Loading v-else class="is-loading-small"/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ $t('misc.cannotBeUndone') }}
|
||||||
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {computed, ref, watchEffect} from 'vue'
|
||||||
|
import {useTitle} from '@/composables/useTitle'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
import {useStore} from 'vuex'
|
||||||
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
|
import {success} from '@/message'
|
||||||
|
import TaskCollectionService from '@/services/taskCollection'
|
||||||
|
import Loading from '@/components/misc/loading.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
const {t} = useI18n()
|
||||||
name: 'list-setting-delete',
|
const store = useStore()
|
||||||
created() {
|
const route = useRoute()
|
||||||
this.setTitle(this.$t('list.delete.title', {list: this.list.title}))
|
const router = useRouter()
|
||||||
},
|
|
||||||
computed: {
|
const totalTasks = ref<number | null>(null)
|
||||||
list() {
|
|
||||||
return this.$store.getters['lists/getListById'](this.$route.params.listId)
|
const list = computed(() => store.getters['lists/getListById'](route.params.listId))
|
||||||
},
|
|
||||||
},
|
watchEffect(
|
||||||
methods: {
|
() => {
|
||||||
async deleteList() {
|
const taskCollectionService = new TaskCollectionService()
|
||||||
await this.$store.dispatch('lists/deleteList', this.list)
|
taskCollectionService.getAll({listId: route.params.listId}).then(() => {
|
||||||
this.$message.success({message: this.$t('list.delete.success')})
|
totalTasks.value = taskCollectionService.totalPages * taskCollectionService.resultCount
|
||||||
this.$router.push({name: 'home'})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
useTitle(() => t('list.delete.title', {list: list.value.title}))
|
||||||
|
|
||||||
|
async function deleteList() {
|
||||||
|
await store.dispatch('lists/deleteList', list)
|
||||||
|
success({message: t('list.delete.success')})
|
||||||
|
router.push({name: 'home'})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue