fix: sharing components
This commit is contained in:
parent
58207db6c3
commit
700fce3c2c
4 changed files with 109 additions and 110 deletions
|
@ -16,7 +16,7 @@
|
||||||
{{ $t('menu.edit') }}
|
{{ $t('menu.edit') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
:to="{ name: 'namespace.settings.share', params: { id: namespace.id } }"
|
:to="{ name: 'namespace.settings.share', params: { namespaceId: namespace.id } }"
|
||||||
icon="share-alt"
|
icon="share-alt"
|
||||||
>
|
>
|
||||||
{{ $t('menu.share') }}
|
{{ $t('menu.share') }}
|
||||||
|
|
|
@ -217,7 +217,7 @@ const router = createRouter({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/namespaces/:id/settings/share',
|
path: '/namespaces/:namespaceId/settings/share',
|
||||||
name: 'namespace.settings.share',
|
name: 'namespace.settings.share',
|
||||||
component: NamespaceSettingShare,
|
component: NamespaceSettingShare,
|
||||||
meta: {
|
meta: {
|
||||||
|
|
|
@ -3,24 +3,38 @@
|
||||||
:title="$t('list.share.header')"
|
:title="$t('list.share.header')"
|
||||||
primary-label=""
|
primary-label=""
|
||||||
>
|
>
|
||||||
<component
|
<template v-if="list">
|
||||||
|
<userTeam
|
||||||
:id="list.id"
|
:id="list.id"
|
||||||
:is="manageUsersComponent"
|
|
||||||
:userIsAdmin="userIsAdmin"
|
:userIsAdmin="userIsAdmin"
|
||||||
shareType="user"
|
shareType="user"
|
||||||
type="list"/>
|
type="list"
|
||||||
<component
|
/>
|
||||||
|
<userTeam
|
||||||
:id="list.id"
|
:id="list.id"
|
||||||
:is="manageTeamsComponent"
|
|
||||||
:userIsAdmin="userIsAdmin"
|
:userIsAdmin="userIsAdmin"
|
||||||
shareType="team"
|
shareType="team"
|
||||||
type="list"/>
|
type="list"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<link-sharing :list-id="$route.params.listId" v-if="linkSharingEnabled" class="mt-4"/>
|
<link-sharing :list-id="listId" v-if="linkSharingEnabled" class="mt-4"/>
|
||||||
</create-edit>
|
</create-edit>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'list-setting-share',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {ref, computed, watchEffect} from 'vue'
|
||||||
|
import {useStore} from 'vuex'
|
||||||
|
import {useRoute} from 'vue-router'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
import {useTitle} from '@vueuse/core'
|
||||||
|
|
||||||
import ListService from '@/services/list'
|
import ListService from '@/services/list'
|
||||||
import ListModel from '@/models/list'
|
import ListModel from '@/models/list'
|
||||||
import {CURRENT_LIST} from '@/store/mutation-types'
|
import {CURRENT_LIST} from '@/store/mutation-types'
|
||||||
|
@ -29,43 +43,30 @@ import CreateEdit from '@/components/misc/create-edit.vue'
|
||||||
import LinkSharing from '@/components/sharing/linkSharing.vue'
|
import LinkSharing from '@/components/sharing/linkSharing.vue'
|
||||||
import userTeam from '@/components/sharing/userTeam.vue'
|
import userTeam from '@/components/sharing/userTeam.vue'
|
||||||
|
|
||||||
export default {
|
const {t} = useI18n()
|
||||||
name: 'list-setting-share',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
list: ListModel,
|
|
||||||
listService: new ListService(),
|
|
||||||
manageUsersComponent: '',
|
|
||||||
manageTeamsComponent: '',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
CreateEdit,
|
|
||||||
LinkSharing,
|
|
||||||
userTeam,
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
linkSharingEnabled() {
|
|
||||||
return this.$store.state.config.linkSharingEnabled
|
|
||||||
},
|
|
||||||
userIsAdmin() {
|
|
||||||
return this.list.owner && this.list.owner.id === this.$store.state.auth.info.id
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.loadList()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async loadList() {
|
|
||||||
const list = new ListModel({id: this.$route.params.listId})
|
|
||||||
|
|
||||||
this.list = await this.listService.get(list)
|
const list = ref()
|
||||||
await this.$store.dispatch(CURRENT_LIST, this.list)
|
const title = computed(() => list.value?.title
|
||||||
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
|
? t('list.share.title', {list: list.value.title})
|
||||||
this.manageTeamsComponent = 'userTeam'
|
: '',
|
||||||
this.manageUsersComponent = 'userTeam'
|
)
|
||||||
this.setTitle(this.$t('list.share.title', {list: this.list.title}))
|
useTitle(title)
|
||||||
},
|
|
||||||
},
|
const store = useStore()
|
||||||
|
const linkSharingEnabled = computed(() => store.state.config.linkSharingEnabled)
|
||||||
|
const userIsAdmin = computed(() => 'owner' in list.value && list.value.owner.id === store.state.auth.info.id)
|
||||||
|
|
||||||
|
async function loadList(listId: number) {
|
||||||
|
const listService = new ListService()
|
||||||
|
const newList = await listService.get(new ListModel({id: listId}))
|
||||||
|
await store.dispatch(CURRENT_LIST, newList)
|
||||||
|
list.value = newList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
</script>
|
||||||
|
|
|
@ -3,69 +3,67 @@
|
||||||
:title="title"
|
:title="title"
|
||||||
primary-label=""
|
primary-label=""
|
||||||
>
|
>
|
||||||
<component
|
<template v-if="namespace">
|
||||||
|
<manageSharing
|
||||||
:id="namespace.id"
|
:id="namespace.id"
|
||||||
:is="manageUsersComponent"
|
|
||||||
:userIsAdmin="userIsAdmin"
|
:userIsAdmin="userIsAdmin"
|
||||||
shareType="user"
|
shareType="user"
|
||||||
type="namespace"/>
|
type="namespace"
|
||||||
<component
|
/>
|
||||||
|
<manageSharing
|
||||||
:id="namespace.id"
|
:id="namespace.id"
|
||||||
:is="manageTeamsComponent"
|
|
||||||
:userIsAdmin="userIsAdmin"
|
:userIsAdmin="userIsAdmin"
|
||||||
shareType="team"
|
shareType="team"
|
||||||
type="namespace"/>
|
type="namespace"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</create-edit>
|
</create-edit>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import manageSharing from '@/components/sharing/userTeam.vue'
|
export default {
|
||||||
import CreateEdit from '@/components/misc/create-edit.vue'
|
name: 'namespace-setting-share',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {ref, computed, watchEffect} from 'vue'
|
||||||
|
import {useStore} from 'vuex'
|
||||||
|
import {useRoute} from 'vue-router'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
import {useTitle} from '@vueuse/core'
|
||||||
|
|
||||||
import NamespaceService from '@/services/namespace'
|
import NamespaceService from '@/services/namespace'
|
||||||
import NamespaceModel from '@/models/namespace'
|
import NamespaceModel from '@/models/namespace'
|
||||||
|
|
||||||
export default {
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
||||||
name: 'namespace-setting-share',
|
import manageSharing from '@/components/sharing/userTeam.vue'
|
||||||
data() {
|
|
||||||
return {
|
const {t} = useI18n()
|
||||||
namespaceService: new NamespaceService(),
|
|
||||||
namespace: new NamespaceModel(),
|
const namespace = ref()
|
||||||
manageUsersComponent: '',
|
|
||||||
manageTeamsComponent: '',
|
const title = computed(() => namespace.value?.title
|
||||||
title: '',
|
? t('namespace.share.title', { namespace: namespace.value.title })
|
||||||
}
|
: '',
|
||||||
},
|
)
|
||||||
components: {
|
useTitle(title)
|
||||||
CreateEdit,
|
|
||||||
manageSharing,
|
const store = useStore()
|
||||||
},
|
const userIsAdmin = computed(() => 'owner' in namespace.value && namespace.value.owner.id === store.state.auth.info.id)
|
||||||
beforeMount() {
|
|
||||||
this.namespace.id = this.$route.params.id
|
async function loadNamespace(namespaceId: number) {
|
||||||
},
|
if (!namespaceId) return
|
||||||
watch: {
|
const namespaceService = new NamespaceService()
|
||||||
// call again the method if the route changes
|
namespace.value = await namespaceService.get(new NamespaceModel({id: namespaceId}))
|
||||||
'$route': {
|
|
||||||
handler: 'loadNamespace',
|
// TODO: set namespace in store
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
userIsAdmin() {
|
|
||||||
return this.namespace.owner && this.namespace.owner.id === this.$store.state.auth.info.id
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async loadNamespace() {
|
|
||||||
const namespace = new NamespaceModel({id: this.$route.params.id})
|
|
||||||
this.namespace = await this.namespaceService.get(namespace)
|
|
||||||
// This will trigger the dynamic loading of components once we actually have all the data to pass to them
|
|
||||||
this.manageTeamsComponent = 'manageSharing'
|
|
||||||
this.manageUsersComponent = 'manageSharing'
|
|
||||||
this.title = this.$t('namespace.share.title', { namespace: this.namespace.title })
|
|
||||||
this.setTitle(this.title)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const namespaceId = computed(() => route.params.namespaceId !== undefined
|
||||||
|
? parseInt(route.params.namespaceId as string)
|
||||||
|
: undefined,
|
||||||
|
)
|
||||||
|
watchEffect(() => namespaceId.value !== undefined && loadNamespace(namespaceId.value))
|
||||||
</script>
|
</script>
|
Loading…
Reference in a new issue