From eea793722538c97e7561278d7a6d4da64b47ac00 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sat, 13 Sep 2025 17:08:30 +0200 Subject: [PATCH] Added Pinning to Standard Entity --- components/EntityShow.vue | 45 +++++++++++++++++++++++++++++++++++++++ components/MainNav.vue | 7 ++++++ plugins/api.ts | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/components/EntityShow.vue b/components/EntityShow.vue index dc3dec8..dbfb20b 100644 --- a/components/EntityShow.vue +++ b/components/EntityShow.vue @@ -45,6 +45,7 @@ const router = useRouter() const route = useRoute() const dataStore = useDataStore() const modal = useModal() +const auth = useAuthStore() const dataType = dataStore.dataTypes[type] @@ -97,6 +98,43 @@ const onTabChange = (index) => { router.push(`${router.currentRoute.value.path}?tabIndex=${index}`) } +const changePinned = async () => { + let newPins = [] + + if(auth.profile.pinned_on_navigation.find(i => i.datatype === type && i.id === props.item.id)){ + //Remove Pin + + newPins = auth.profile.pinned_on_navigation.filter(i => !(i.datatype === type && i.id === props.item.id)) + } else { + //Add Pin + + newPins = [ + ...auth.profile.pinned_on_navigation, + { + id: props.item.id, + icon: "i-heroicons-document", + type: "standardEntity", + datatype: type, + label: props.item[dataType.templateColumns.find(i => i.title).key] + } + ] + } + + const res = await useNuxtApp().$api(`/api/user/${auth.user.id}/profile`,{ + method: "PUT", + body: { + data: { + pinned_on_navigation: newPins + } + } + }) + + await auth.fetchMe() + + + +} +