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/archive.vue

49 lines
1.2 KiB
Vue
Raw Normal View History

<template>
2022-11-14 18:02:28 +00:00
<modal @submit="archiveList">
<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>
</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
const {t} = useI18n({useScope: 'global'})
const listStore = useListStore()
2022-05-21 15:27:06 +00:00
const route = useRoute()
const list = computed(() => listStore.getListById(route.params.listId))
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 {
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
}
}
</script>