ff-admin/src/views/admin/View.vue

74 lines
2.1 KiB
Vue
Raw Normal View History

2024-08-23 14:42:32 +02:00
<template>
<SidebarLayout>
<template #sidebar>
<SidebarTemplate
:mainTitle="activeNavigationObject.mainTitle"
:topTitle="activeNavigationObject.topTitle"
:showTopList="activeNavigationObject.top != null"
>
<template #topList>
2024-11-16 12:19:13 +01:00
<RoutingLink
v-for="item in activeNavigationObject.top"
:key="item.key"
:title="item.title"
:link="{ name: `admin-${activeNavigation}-${item.key}` }"
:active="activeLink == item.key"
/>
2024-08-23 14:42:32 +02:00
</template>
<template #list>
2025-01-12 18:17:50 +01:00
<div v-for="item in activeNavigationObject.main" :key="item.key">
<RoutingLink
v-if="!item.key.includes('divider')"
:title="item.title"
:link="{ name: `admin-${activeNavigation}-${item.key}` }"
:active="activeLink == item.key"
/>
<p v-else class="pt-4 border-b border-gray-300">{{ item.title }}</p>
</div>
2024-08-23 14:42:32 +02:00
</template>
</SidebarTemplate>
</template>
<template #main>
2024-09-01 19:19:48 +02:00
<RouterView />
2024-08-23 14:42:32 +02:00
</template>
</SidebarLayout>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapState, mapActions } from "pinia";
import { useNavigationStore } from "@/stores/admin/navigation";
import SidebarLayout from "@/layouts/Sidebar.vue";
import SidebarTemplate from "@/templates/Sidebar.vue";
import RoutingLink from "@/components/admin/RoutingLink.vue";
2024-09-17 16:44:02 +02:00
import { useAbilityStore } from "@/stores/ability";
import { RouterView } from "vue-router";
2024-08-23 14:42:32 +02:00
</script>
<script lang="ts">
export default defineComponent({
computed: {
2024-11-16 12:19:13 +01:00
...mapState(useNavigationStore, [
"activeNavigationObject",
"activeTopLevelObject",
"activeLink",
"activeNavigation",
]),
2024-08-23 14:42:32 +02:00
},
created() {
useAbilityStore().$subscribe(() => {
this.updateTopLevel();
this.updateNavigation();
});
2024-12-23 14:06:15 +01:00
this.updateTopLevel();
this.updateNavigation();
2024-08-23 14:42:32 +02:00
},
beforeUnmount() {
this.resetNavigation();
},
methods: {
2024-09-01 19:19:48 +02:00
...mapActions(useNavigationStore, ["resetNavigation", "updateTopLevel", "updateNavigation"]),
2024-08-23 14:42:32 +02:00
},
});
</script>