feat: #8217 implement onBeforeSave function for form data processing #1631

Open
jsegarra wants to merge 19 commits from 8217_mapper into dev
2 changed files with 4 additions and 10 deletions
Showing only changes of commit 342d0a6b1e - Show all commits

View File

@ -111,7 +111,7 @@ const isLoading = ref(false);
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
const isResetting = ref(false);
const hasChanges = ref(!$props.observeFormChanges);
const originalData = computed(() => state.get(modelValue));
const originalData = computed(() => state.get(modelValue) ?? {});
const formData = ref();
const defaultButtons = computed(() => ({
save: {

View File

@ -1,16 +1,10 @@
export default function getDifferences(initialData, formData) {
const differences = {};
delete initialData.$index;
delete formData.$index;
if (initialData) delete initialData.$index;
if (formData) delete formData.$index;
for (const key in formData) {
if (formData.hasOwnProperty(key)) {
if (
!initialData ||
!initialData.hasOwnProperty(key) ||
formData[key] !== initialData[key]
) {
//Añadir la diferencia solo si existe initialData
if (!initialData.hasOwnProperty(key) || formData[key] !== initialData[key]) {
if (initialData) {
differences[key] = formData[key];
}