Improve reactivity of card descriptor
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
William Buezas 2024-02-26 09:54:59 -03:00
parent 90bfba0290
commit 740eedbe44
3 changed files with 11 additions and 12 deletions

View File

@ -59,6 +59,10 @@ const $props = defineProps({
type: Function,
default: null,
},
clearStoreOnUnmount: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(['onFetch', 'onDataSaved']);
@ -91,7 +95,12 @@ onMounted(async () => {
});
onUnmounted(() => {
state.unset($props.model);
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
if (hasChanges.value) {
state.set($props.model, originalData.value);
return;
}
if ($props.clearStoreDataOnUnmount) state.unset($props.model);
});
const isLoading = ref(false);

View File

@ -61,6 +61,7 @@ const onFilterTravelSelected = (formData, id) => {
:url-update="`Entries/${route.params.id}`"
model="entry"
auto-load
:clear-store-on-unmount="false"
>
<template #form="{ data }">
<VnRow class="row q-gutter-md q-mb-md">

View File

@ -97,17 +97,6 @@ const getEntryRedirectionFilter = (entry) => {
});
};
const refetchEntryDescriptorData = async () => {
await entryDescriptorRef.value.getData();
};
watch(
() => route.name,
async (_, from) => {
if (from === 'EntryBasicData') await refetchEntryDescriptorData();
}
);
const showEntryReport = () => {
openReport(`Entries/${route.params.id}/entry-order-pdf`);
};