2021-01-30 16:17:04 +00:00
|
|
|
<template>
|
2022-11-14 18:02:28 +00:00
|
|
|
<modal @submit="archiveList">
|
2021-08-19 17:55:13 +00:00
|
|
|
<template #header><span>{{ list.isArchived ? $t('list.archive.unarchive') : $t('list.archive.archive') }}</span></template>
|
|
|
|
|
|
|
|
<template #text>
|
|
|
|
<p>{{ list.isArchived ? $t('list.archive.unarchiveText') : $t('list.archive.archiveText') }}</p>
|
|
|
|
</template>
|
2021-01-30 16:17:04 +00:00
|
|
|
</modal>
|
|
|
|
</template>
|
|
|
|
|
2022-02-15 12:07:34 +00:00
|
|
|
<script lang="ts">
|
2022-06-23 01:08:35 +00:00
|
|
|
export default {name: 'list-setting-archive'}
|
2022-05-21 15:27:06 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-06-30 16:04:41 +00:00
|
|
|
import {computed} from 'vue'
|
2022-11-14 18:02:28 +00:00
|
|
|
import {useRoute} from 'vue-router'
|
2022-05-21 15:27:06 +00:00
|
|
|
import {useI18n} from 'vue-i18n'
|
|
|
|
|
2022-09-24 13:20:40 +00:00
|
|
|
import {success} from '@/message'
|
|
|
|
import {useTitle} from '@/composables/useTitle'
|
|
|
|
|
|
|
|
import {useBaseStore} from '@/stores/base'
|
|
|
|
import {useListStore} from '@/stores/lists'
|
2022-05-21 15:27:06 +00:00
|
|
|
|
2022-05-23 05:23:59 +00:00
|
|
|
const {t} = useI18n({useScope: 'global'})
|
2022-09-21 16:21:25 +00:00
|
|
|
const listStore = useListStore()
|
2022-05-21 15:27:06 +00:00
|
|
|
const route = useRoute()
|
|
|
|
|
2022-09-21 16:21:25 +00:00
|
|
|
const list = computed(() => listStore.getListById(route.params.listId))
|
2022-11-22 11:43:07 +00:00
|
|
|
useTitle(() => list.value
|
|
|
|
? t('list.archive.title', {list: list.value.title})
|
|
|
|
: undefined,
|
|
|
|
)
|
2022-05-21 15:27:06 +00:00
|
|
|
|
2022-11-14 18:02:28 +00:00
|
|
|
async function archiveList(onClose: () => void) {
|
2022-05-21 15:27:06 +00:00
|
|
|
try {
|
2022-09-21 16:21:25 +00:00
|
|
|
const newList = await listStore.updateList({
|
2022-06-30 16:04:41 +00:00
|
|
|
...list.value,
|
2022-05-21 15:27:06 +00:00
|
|
|
isArchived: !list.value.isArchived,
|
|
|
|
})
|
2022-09-24 13:20:40 +00:00
|
|
|
useBaseStore().setCurrentList(newList)
|
2022-05-21 15:27:06 +00:00
|
|
|
success({message: t('list.archive.success')})
|
|
|
|
} finally {
|
2022-11-14 18:02:28 +00:00
|
|
|
onClose()
|
2022-05-21 15:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-30 16:17:04 +00:00
|
|
|
</script>
|