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

77 lines
2.0 KiB
Vue
Raw Normal View History

<template>
<create-edit
:title="$t('list.share.header')"
:has-primary-action="false"
>
2021-11-30 15:58:15 +00:00
<template v-if="list">
<userTeam
:id="list.id"
:userIsAdmin="userIsAdmin"
shareType="user"
type="list"
/>
<userTeam
:id="list.id"
:userIsAdmin="userIsAdmin"
shareType="team"
type="list"
/>
</template>
2021-11-30 15:58:15 +00:00
<link-sharing :list-id="listId" v-if="linkSharingEnabled" class="mt-4"/>
</create-edit>
</template>
2021-11-30 15:58:15 +00:00
<script lang="ts">
2022-06-23 01:08:35 +00:00
export default {name: 'list-setting-share'}
2021-11-30 15:58:15 +00:00
</script>
<script lang="ts" setup>
import {ref, computed, watchEffect} from 'vue'
import {useRoute} from 'vue-router'
import {useI18n} from 'vue-i18n'
import {useTitle} from '@vueuse/core'
import ListService from '@/services/list'
import ListModel from '@/models/list'
import type {IList} from '@/modelTypes/IList'
import {RIGHTS} from '@/constants/rights'
import CreateEdit from '@/components/misc/create-edit.vue'
import LinkSharing from '@/components/sharing/linkSharing.vue'
import userTeam from '@/components/sharing/userTeam.vue'
2022-09-24 13:20:40 +00:00
import {useBaseStore} from '@/stores/base'
2022-09-21 00:21:22 +00:00
import {useConfigStore} from '@/stores/config'
2022-09-21 01:37:39 +00:00
import {useAuthStore} from '@/stores/auth'
const {t} = useI18n({useScope: 'global'})
2021-11-30 15:58:15 +00:00
const list = ref<IList>()
2021-11-30 15:58:15 +00:00
const title = computed(() => list.value?.title
? t('list.share.title', {list: list.value.title})
: '',
)
useTitle(title)
2022-09-21 01:37:39 +00:00
const authStore = useAuthStore()
2022-09-21 00:21:22 +00:00
const configStore = useConfigStore()
const linkSharingEnabled = computed(() => configStore.linkSharingEnabled)
const userIsAdmin = computed(() => list?.value?.maxRight === RIGHTS.ADMIN)
2021-11-30 15:58:15 +00:00
async function loadList(listId: number) {
const listService = new ListService()
const newList = await listService.get(new ListModel({id: listId}))
2022-09-24 13:20:40 +00:00
await useBaseStore().handleSetCurrentList({list: newList})
2021-11-30 15:58:15 +00:00
list.value = newList
}
2021-11-30 15:58:15 +00:00
const route = useRoute()
const listId = computed(() => route.params.listId !== undefined
? parseInt(route.params.listId as string)
: undefined,
)
watchEffect(() => listId.value !== undefined && loadList(listId.value))
</script>