navigation enhancement

This commit is contained in:
Julian Krauser 2024-12-23 14:06:15 +01:00
parent 2853835d31
commit b3125a26da
3 changed files with 11 additions and 7 deletions

View file

@ -21,7 +21,7 @@
</div> </div>
<div class="px-1 py-1 w-full flex flex-col gap-2"> <div class="px-1 py-1 w-full flex flex-col gap-2">
<MenuItem v-slot="{ close }"> <MenuItem v-slot="{ close }">
<RouterLink to="/account"> <RouterLink to="/account/me">
<button button primary @click="close">Mein Account</button> <button button primary @click="close">Mein Account</button>
</RouterLink> </RouterLink>
</MenuItem> </MenuItem>

View file

@ -46,7 +46,7 @@ export const useNavigationStore = defineStore("navigation", {
resetNavigation() { resetNavigation() {
this.$reset(); this.$reset();
}, },
updateTopLevel(first: boolean = false) { updateTopLevel() {
const abilityStore = useAbilityStore(); const abilityStore = useAbilityStore();
this.topLevel = [ this.topLevel = [
...(abilityStore.canSection("read", "club") ...(abilityStore.canSection("read", "club")
@ -82,7 +82,7 @@ export const useNavigationStore = defineStore("navigation", {
router.push({ name: `admin-${this.topLevel[0]?.key ?? "club"}-default` }); router.push({ name: `admin-${this.topLevel[0]?.key ?? "club"}-default` });
} }
}, },
updateNavigation(first: boolean = false) { updateNavigation() {
const abilityStore = useAbilityStore(); const abilityStore = useAbilityStore();
this.navigation = { this.navigation = {
club: { club: {
@ -129,8 +129,12 @@ export const useNavigationStore = defineStore("navigation", {
], ],
}, },
} as navigationModel; } as navigationModel;
if (this.activeNavigationObject.main.findIndex((e) => e.key == this.activeLink) == -1) { if (
router.push({ name: `admin-${this.activeNavigation}-default` }); this.activeNavigationObject.main.findIndex((e) => e.key == this.activeLink) == -1 ||
this.activeLink == "default"
) {
let link = this.activeNavigationObject.main[0].key;
router.push({ name: `admin-${this.activeNavigation}-${link}` });
} }
}, },
}, },

View file

@ -58,8 +58,8 @@ export default defineComponent({
this.updateTopLevel(); this.updateTopLevel();
this.updateNavigation(); this.updateNavigation();
}); });
this.updateTopLevel(true); this.updateTopLevel();
this.updateNavigation(true); this.updateNavigation();
}, },
beforeUnmount() { beforeUnmount() {
this.resetNavigation(); this.resetNavigation();