From 361024abe282a23cbcff0197b5addf72d6ae6884 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 29 Jun 2024 00:07:00 +0200 Subject: [PATCH] feat: #7648 handle LeftMenu --- src/components/LeftMenu.vue | 7 +++++-- src/stores/useNavigationStore.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/LeftMenu.vue b/src/components/LeftMenu.vue index 3cccd0d2f..0dfcc812e 100644 --- a/src/components/LeftMenu.vue +++ b/src/components/LeftMenu.vue @@ -9,6 +9,7 @@ import { toLowerCamel } from 'src/filters'; import routes from 'src/router/modules'; import LeftMenuItem from './LeftMenuItem.vue'; import LeftMenuItemGroup from './LeftMenuItemGroup.vue'; +import { useRole } from 'src/composables/useRole'; const { t } = useI18n(); const route = useRoute(); @@ -58,6 +59,8 @@ function addChildren(module, route, parent) { } const items = ref([]); +const role = useRole(); + function getRoutes() { if (props.source === 'main') { const modules = Object.assign([], navigation.getModules().value); @@ -66,9 +69,9 @@ function getRoutes() { const moduleDef = routes.find( (route) => toLowerCamel(route.name) === item.module ); - item.children = []; - if (!moduleDef) continue; + if (!role.isEmployee()) continue; + item.children = []; addChildren(item.module, moduleDef, item.children); } diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index 4dd5ed2ae..da06730f7 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -80,7 +80,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { } async function fetchPinned() { - if (pinnedModules.value.length) return; + if (pinnedModules.value.length || !role.isEmployee()) return; const response = await axios.get('StarredModules/getStarredModules'); pinnedModules.value = response.data.map((row) => row.moduleFk);