fix: fixed department descriptor icon
gitea/salix-front/pipeline/pr-test There was a failure building this commit Details

This commit is contained in:
Jon Elias 2025-03-18 13:59:13 +01:00
parent c1f5a9ab4d
commit 1caa3055f3
3 changed files with 52 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';
@ -38,10 +38,15 @@ const $props = defineProps({
type: String, type: String,
default: 'md-width', default: 'md-width',
}, },
toModule: {
type: String,
default: null,
},
}); });
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 +55,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 +84,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 +131,41 @@ 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 ($props.toModule) {
? route.matched[1].redirect return router
: route.matched[1].children[0].redirect, .getRoutes()
); .find((r) => r.name && r.name.includes($props.toModule.name)).meta.icon;
}
if (isSameModuleName) {
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
?.meta?.icon;
} else {
return route.matched[1].meta.icon;
}
});
const toModule = computed(() => {
moduleName.value = getName();
if ($props.toModule) return $props.toModule;
if (isSameModuleName) {
return router.options.routes[1].children.find((r) => r.name === moduleName.value)
?.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 +173,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
@ -158,6 +190,7 @@ const toModule = computed(() =>
color="white" color="white"
class="link" class="link"
v-if="summary" v-if="summary"
data-cy="openSummaryBtn"
> >
<QTooltip> <QTooltip>
{{ t('components.smartCard.openSummary') }} {{ t('components.smartCard.openSummary') }}
@ -172,6 +205,7 @@ const toModule = computed(() =>
icon="launch" icon="launch"
round round
size="md" size="md"
data-cy="goToSummaryBtn"
> >
<QTooltip> <QTooltip>
{{ t('components.cardDescriptor.summary') }} {{ t('components.cardDescriptor.summary') }}
@ -230,7 +264,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

View File

@ -37,6 +37,7 @@ const removeRole = async () => {
:filter="{ where: { id: entityId } }" :filter="{ where: { id: entityId } }"
data-key="Role" data-key="Role"
:summary="$props.summary" :summary="$props.summary"
:to-module="{ name: 'AccountRoles' }"
> >
<template #menu> <template #menu>
<QItem v-ripple clickable @click="removeRole()"> <QItem v-ripple clickable @click="removeRole()">

View File

@ -271,6 +271,7 @@ export default {
path: 'department', path: 'department',
name: 'Department', name: 'Department',
redirect: { name: 'WorkerDepartment' }, redirect: { name: 'WorkerDepartment' },
meta: { title: 'department', icon: 'vn:greuge' },
component: () => import('src/pages/Worker/WorkerDepartment.vue'), component: () => import('src/pages/Worker/WorkerDepartment.vue'),
children: [ children: [
{ {