This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/views/list/settings/delete.vue

64 lines
1.5 KiB
Vue
Raw Normal View History

<template>
<modal
@close="$router.back()"
@submit="deleteList()"
>
<template #header><span>{{ $t('list.delete.header') }}</span></template>
<template #text>
<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>
</modal>
</template>
<script setup lang="ts">
2022-10-05 12:41:07 +00:00
import {ref, watch} from 'vue'
import {useTitle} from '@/composables/useTitle'
import {useI18n} from 'vue-i18n'
import TaskCollectionService from '@/services/taskCollection'
import Loading from '@/components/misc/loading.vue'
2022-10-04 21:30:17 +00:00
2022-10-05 12:41:07 +00:00
import {useList} from '@/stores/lists'
2022-10-04 21:30:17 +00:00
import type {IList} from '@/modelTypes/IList'
const {listId} = defineProps<{
listId: IList['id']
}>()
2022-02-15 12:07:59 +00:00
const {t} = useI18n({useScope: 'global'})
const totalTasks = ref<number | null>(null)
2022-10-04 21:30:17 +00:00
watch(
() => listId,
async (currentListId) => {
if (!currentListId) {
return
}
const taskCollectionService = new TaskCollectionService()
2022-10-04 21:30:17 +00:00
await taskCollectionService.getAll({listId: currentListId})
totalTasks.value = taskCollectionService.totalPages * taskCollectionService.resultCount
},
{immediate: true},
)
2022-10-05 12:41:07 +00:00
const {list, deleteList} = useList(listId)
useTitle(() => t('list.delete.title', {list: list?.value?.title}))
</script>