From dc83d50e96e1882b98499eb5addc1acbf55ad998 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 16 Dec 2024 14:30:23 +0100 Subject: [PATCH] refactor: refs #8197 backward compatible --- src/components/LeftMenu.vue | 31 ++++++++--- src/components/common/VnCard.vue | 45 +++++++++++---- src/components/common/VnCardBeta.vue | 65 ++++++++++++++++++++++ src/pages/Account/Alias/Card/AliasCard.vue | 4 +- src/pages/Account/Card/AccountCard.vue | 4 +- src/pages/Account/Role/Card/RoleCard.vue | 4 +- 6 files changed, 128 insertions(+), 25 deletions(-) create mode 100644 src/components/common/VnCardBeta.vue diff --git a/src/components/LeftMenu.vue b/src/components/LeftMenu.vue index eed2e192b..09e126213 100644 --- a/src/components/LeftMenu.vue +++ b/src/components/LeftMenu.vue @@ -92,8 +92,10 @@ function findMatches(search, item) { } function addChildren(module, route, parent) { - if (!route?.meta?.menu) return; - const matches = findMatches(route.meta.menu, route); + const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible + if (!menus) return; + + const matches = findMatches(menus, route); for (const child of matches) { navigation.addMenuItem(module, child, parent); @@ -118,17 +120,28 @@ function getRoutes() { } if (props.source === 'card') { - let menuRoute; - let index = route.matched.length - 1; + const currentRoute = route.matched[1]; + const currentModule = toLowerCamel(currentRoute.name); + let moduleDef = routes.find( + (route) => toLowerCamel(route.name) === currentModule + ); - while (!menuRoute && index > 0) { - if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index]; - index--; - } - addChildren('', menuRoute, items.value); + if (!moduleDef) return; + if (!moduleDef?.menus) moduleDef = betaGetRoutes(); + addChildren(currentModule, moduleDef, items.value); } } +function betaGetRoutes() { + let menuRoute; + let index = route.matched.length - 1; + while (!menuRoute && index > 0) { + if (route.matched[index]?.meta?.menu) menuRoute = route.matched[index]; + index--; + } + return menuRoute; +} + async function togglePinned(item, event) { if (event.defaultPrevented) return; event.preventDefault(); diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 16a077a79..0d80f43ce 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -4,7 +4,10 @@ import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router'; import { useArrayData } from 'src/composables/useArrayData'; import { useStateStore } from 'stores/useStateStore'; import useCardSize from 'src/composables/useCardSize'; +import VnSubToolbar from '../ui/VnSubToolbar.vue'; +import VnSearchbar from 'components/ui/VnSearchbar.vue'; import LeftMenu from 'components/LeftMenu.vue'; +import RightMenu from 'components/common/RightMenu.vue'; const props = defineProps({ dataKey: { type: String, required: true }, baseUrl: { type: String, default: undefined }, @@ -26,7 +29,10 @@ const url = computed(() => { } return props.customUrl; }); - +const searchRightDataKey = computed(() => { + if (!props.searchDataKey) return route.name; + return props.searchDataKey; +}); const arrayData = useArrayData(props.dataKey, { url: url.value, filter: props.filter, @@ -53,13 +59,32 @@ if (props.baseUrl) { } diff --git a/src/components/common/VnCardBeta.vue b/src/components/common/VnCardBeta.vue new file mode 100644 index 000000000..16a077a79 --- /dev/null +++ b/src/components/common/VnCardBeta.vue @@ -0,0 +1,65 @@ + + diff --git a/src/pages/Account/Alias/Card/AliasCard.vue b/src/pages/Account/Alias/Card/AliasCard.vue index 65951b3bf..3a814edc0 100644 --- a/src/pages/Account/Alias/Card/AliasCard.vue +++ b/src/pages/Account/Alias/Card/AliasCard.vue @@ -1,12 +1,12 @@