diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 9fd16088c..00703d516 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -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); diff --git a/src/pages/Entry/Card/EntryBasicData.vue b/src/pages/Entry/Card/EntryBasicData.vue index a98a1227f..4a8cf154a 100644 --- a/src/pages/Entry/Card/EntryBasicData.vue +++ b/src/pages/Entry/Card/EntryBasicData.vue @@ -61,6 +61,7 @@ const onFilterTravelSelected = (formData, id) => { :url-update="`Entries/${route.params.id}`" model="entry" auto-load + :clear-store-on-unmount="false" >