feat(Shelving): add DescriptorMenu

This commit is contained in:
Alex Moreno 2024-11-24 11:16:08 +01:00
parent b93633fc77
commit ed3ad310c5
5 changed files with 19 additions and 8 deletions

View File

@ -48,7 +48,6 @@ let store;
let entity;
const isLoading = ref(false);
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
const menuRef = ref();
defineExpose({ getData });
onBeforeMount(async () => {
@ -161,7 +160,7 @@ const toModule = computed(() =>
</QBtn>
</RouterLink>
<VnMoreOptions v-if="$slots.menu">
<template #menu>
<template #menu="{ menuRef }">
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
</template>
</VnMoreOptions>

View File

@ -87,8 +87,8 @@ async function fetch() {
<span class="row no-wrap">
<slot name="header-right" :entity="entity" />
<VnMoreOptions v-if="$slots.menu && isDialogOpened()">
<template #menu>
<slot name="menu" :entity="entity" />
<template #menu="{ menuRef }">
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
</template>
</VnMoreOptions>
</span>

View File

@ -13,7 +13,7 @@
</QTooltip>
<QMenu ref="menuRef">
<QList>
<slot name="menu" />
<slot name="menu" :menu-ref="$refs.menuRef" />
</QList>
</QMenu>
</QBtn>

View File

@ -4,6 +4,7 @@ import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnConfirm from 'components/ui/VnConfirm.vue';
import { useRoute } from 'vue-router';
const $props = defineProps({
shelving: {
@ -14,8 +15,11 @@ const $props = defineProps({
const router = useRouter();
const quasar = useQuasar();
const route = useRoute();
const { t } = useI18n();
const emit = defineEmits(['onRemove']);
function confirmRemove() {
quasar.dialog({
component: VnConfirm,
@ -32,11 +36,12 @@ async function remove() {
return;
}
await axios.delete(`Shelvings/${$props.shelving.id}`);
await router.push({ name: 'ShelvingList' });
if (route.name != 'ShelvingList') await router.push({ name: 'ShelvingList' });
quasar.notify({
message: t('globals.dataDeleted'),
type: 'positive',
});
emit('onRemove', {});
}
</script>
<template>

View File

@ -1,10 +1,11 @@
<script setup>
import { computed } from 'vue';
import { computed, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'components/ui/VnLv.vue';
import VnUserLink from 'components/ui/VnUserLink.vue';
import ShelvingDescriptorMenu from './ShelvingDescriptorMenu.vue';
const $props = defineProps({
id: {
@ -14,7 +15,7 @@ const $props = defineProps({
});
const route = useRoute();
const { t } = useI18n();
const summary = ref({});
const entityId = computed(() => $props.id || route.params.id);
const filter = {
@ -45,6 +46,12 @@ const filter = {
<template #header="{ entity }">
<div>{{ entity.code }}</div>
</template>
<template #menu="{ entity }">
<ShelvingDescriptorMenu
:shelving="entity"
@on-remove="$refs.summary.fetch()"
/>
</template>
<template #body="{ entity }">
<QCard class="vn-one">
<RouterLink