From ad6b335d41e07e8ce2e74e4282d572ba4c04ea30 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Tue, 13 Sep 2022 17:33:56 +0200 Subject: [PATCH] feat: namespace settings archive script setup --- src/composables/useTitle.ts | 23 ++++-- src/router/index.ts | 1 + src/views/namespaces/settings/archive.vue | 99 +++++++++++++++-------- 3 files changed, 81 insertions(+), 42 deletions(-) diff --git a/src/composables/useTitle.ts b/src/composables/useTitle.ts index 62d30623..981e4d59 100644 --- a/src/composables/useTitle.ts +++ b/src/composables/useTitle.ts @@ -1,12 +1,21 @@ -import { computed, watchEffect } from 'vue' -import type { ComputedGetter } from 'vue' +import { computed } from 'vue' +import type { Ref } from 'vue' -import { setTitle } from '@/helpers/setTitle' +import {useTitle as useTitleVueUse, resolveRef} from '@vueuse/core' -export function useTitle(titleGetter: ComputedGetter) { - const titleRef = computed(titleGetter) +type UseTitleParameters = Parameters - watchEffect(() => setTitle(titleRef.value)) +export function useTitle(...args: UseTitleParameters) { - return titleRef + const [newTitle, ...restArgs] = args + + const pageTitle = resolveRef(newTitle) as Ref + + const completeTitle = computed(() => + (typeof pageTitle.value === 'undefined' || pageTitle.value === '') + ? 'Vikunja' + : `${pageTitle.value} | Vikunja`, + ) + + return useTitleVueUse(completeTitle, ...restArgs) } \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 2b3e6304..b69ea366 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -238,6 +238,7 @@ const router = createRouter({ meta: { showAsModal: true, }, + props: route => ({ namespaceId: parseInt(route.params.id as string) }), }, { path: '/namespaces/:id/settings/delete', diff --git a/src/views/namespaces/settings/archive.vue b/src/views/namespaces/settings/archive.vue index 7903ef61..950c1c12 100644 --- a/src/views/namespaces/settings/archive.vue +++ b/src/views/namespaces/settings/archive.vue @@ -7,50 +7,79 @@ + +