feat: refs #8045 added new logic to show the correct icon and the correct path to redirect

This commit is contained in:
Jon Elias 2025-02-28 07:53:20 +01:00
parent 561f82fa08
commit d64ac223e3
1 changed files with 33 additions and 16 deletions

View File

@ -51,6 +51,9 @@ let store;
let entity; let entity;
const isLoading = ref(false); const isLoading = ref(false);
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName); const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
const DESCRIPTOR_PROXY = 'DescriptorProxy';
const moduleName = ref();
const isSameModuleName = route.matched[1].meta.moduleName !== moduleName.value;
defineExpose({ getData }); defineExpose({ getData });
onBeforeMount(async () => { onBeforeMount(async () => {
@ -77,15 +80,18 @@ onBeforeMount(async () => {
); );
}); });
const routeName = computed(() => { function getName() {
const DESCRIPTOR_PROXY = 'DescriptorProxy';
let name = $props.dataKey; let name = $props.dataKey;
if ($props.dataKey.includes(DESCRIPTOR_PROXY)) { if ($props.dataKey.includes(DESCRIPTOR_PROXY)) {
name = name.split(DESCRIPTOR_PROXY)[0]; name = name.split(DESCRIPTOR_PROXY)[0];
} }
return `${name}Summary`; return name;
}
const routeName = computed(() => {
let routeName = getName();
return `${routeName}Summary`;
}); });
async function getData() { async function getData() {
store.url = $props.url; store.url = $props.url;
store.filter = $props.filter ?? {}; store.filter = $props.filter ?? {};
@ -121,16 +127,27 @@ function copyIdText(id) {
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
const iconModule = computed( const iconModuleV = computed(() => {
() => moduleName.value = getName();
router.options.routes[1].children.find((r) => r.name === $props.dataKey).meta if (isSameModuleName) {
.icon, return router.options.routes[1].children.find((r) => r.name === moduleName.value)
); ?.meta?.icon;
const toModule = computed( } else {
() => return route.matched[1].meta.icon;
router.options.routes[1].children.find((r) => r.name === $props.dataKey) }
.children[0].redirect, });
);
const toModuleV = computed(() => {
moduleName.value = getName();
if (isSameModuleName) {
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
?.children[0]?.redirect;
} else {
return route.matched[1].path.split('/').length > 2
? route.matched[1].redirect
: route.matched[1].children[0].redirect;
}
});
</script> </script>
<template> <template>
@ -143,10 +160,10 @@ const toModule = computed(
flat flat
dense dense
size="md" size="md"
:icon="iconModule" :icon="iconModuleV"
color="white" color="white"
class="link" class="link"
:to="toModule" :to="toModuleV"
> >
<QTooltip> <QTooltip>
{{ t('globals.goToModuleIndex') }} {{ t('globals.goToModuleIndex') }}