Merge pull request '#8045: Modified redirect from CardDescriptor' (!1495) from 8045-FixIconDescriptorRedirect into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1495
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jon Elias 2025-03-07 12:09:20 +00:00
commit 1f0414bd91
1 changed files with 38 additions and 17 deletions

View File

@ -5,7 +5,7 @@ import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useRoute } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useClipboard } from 'src/composables/useClipboard'; import { useClipboard } from 'src/composables/useClipboard';
import VnMoreOptions from './VnMoreOptions.vue'; import VnMoreOptions from './VnMoreOptions.vue';
@ -42,6 +42,7 @@ const $props = defineProps({
const state = useState(); const state = useState();
const route = useRoute(); const route = useRoute();
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { copyText } = useClipboard(); const { copyText } = useClipboard();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
@ -50,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 () => {
@ -76,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 ?? {};
@ -120,20 +127,35 @@ function copyIdText(id) {
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
const iconModule = computed(() => route.matched[1].meta.icon); const iconModule = computed(() => {
const toModule = computed(() => moduleName.value = getName();
route.matched[1].path.split('/').length > 2 if (isSameModuleName) {
? route.matched[1].redirect return router.options.routes[1].children.find((r) => r.name === moduleName.value)
: route.matched[1].children[0].redirect, ?.meta?.icon;
); } else {
return route.matched[1].meta.icon;
}
});
const toModule = 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>
<div class="descriptor"> <div class="descriptor">
<template v-if="entity && !isLoading"> <template v-if="entity && !isLoading">
<div class="header bg-primary q-pa-sm justify-between"> <div class="header bg-primary q-pa-sm justify-between">
<slot name="header-extra-action" <slot name="header-extra-action">
><QBtn <QBtn
round round
flat flat
dense dense
@ -141,13 +163,13 @@ const toModule = computed(() =>
:icon="iconModule" :icon="iconModule"
color="white" color="white"
class="link" class="link"
:to="$attrs['to-module'] ?? toModule" :to="toModule"
> >
<QTooltip> <QTooltip>
{{ t('globals.goToModuleIndex') }} {{ t('globals.goToModuleIndex') }}
</QTooltip> </QTooltip>
</QBtn></slot </QBtn>
> </slot>
<QBtn <QBtn
@click.stop="viewSummary(entity.id, $props.summary, $props.width)" @click.stop="viewSummary(entity.id, $props.summary, $props.width)"
round round
@ -230,7 +252,6 @@ const toModule = computed(() =>
</div> </div>
<slot name="after" /> <slot name="after" />
</template> </template>
<!-- Skeleton -->
<SkeletonDescriptor v-if="!entity || isLoading" /> <SkeletonDescriptor v-if="!entity || isLoading" />
</div> </div>
<QInnerLoading <QInnerLoading