From 97dc299cfee80875698329a5acb4b4a5349516e7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 6 Jun 2024 09:53:48 +0200 Subject: [PATCH 1/4] fix: refs #6942 fix emit on data saved --- src/components/FormModel.vue | 14 +++++++------- src/pages/InvoiceIn/InvoiceInCreate.vue | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 03f75477d..f88bf47c4 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -117,7 +117,7 @@ onMounted(async () => { state.set($props.model, $props.formInitialData); if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch(); - else if (arrayData.store.data) updateAndEmit(arrayData.store.data, 'onFetch'); + else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data); if ($props.observeFormChanges) { watch( @@ -137,7 +137,7 @@ onMounted(async () => { if (!$props.url) watch( () => arrayData.store.data, - (val) => updateAndEmit(val, 'onFetch') + (val) => updateAndEmit('onFetch', val) ); watch(formUrl, async () => { @@ -172,8 +172,8 @@ async function fetch() { }); if (Array.isArray(data)) data = data[0] ?? {}; - updateAndEmit(data, 'onFetch'); - } catch (error) { + updateAndEmit('onFetch', data); + } catch (e) { state.set($props.model, {}); originalData.value = {}; } @@ -199,7 +199,7 @@ async function save() { hasChanges.value = false; isLoading.value = false; - updateAndEmit(response?.data, 'onDataSaved'); + updateAndEmit('onDataSaved', formData.value, response?.data); } catch (err) { console.error(err); notify('errors.writeRequest', 'negative'); @@ -234,12 +234,12 @@ function filter(value, update, filterOptions) { ); } -function updateAndEmit(val, evt) { +function updateAndEmit(evt, val, res) { state.set($props.model, val); originalData.value = val && JSON.parse(JSON.stringify(val)); if (!$props.url) arrayData.store.data = val; - emit(evt, state.get($props.model)); + emit(evt, state.get($props.model), res); } defineExpose({ save, isLoading, hasChanges }); diff --git a/src/pages/InvoiceIn/InvoiceInCreate.vue b/src/pages/InvoiceIn/InvoiceInCreate.vue index df73a0005..4dec9ac7d 100644 --- a/src/pages/InvoiceIn/InvoiceInCreate.vue +++ b/src/pages/InvoiceIn/InvoiceInCreate.vue @@ -29,7 +29,7 @@ const newInvoiceIn = reactive({ const suppliersOptions = ref([]); const companiesOptions = ref([]); -const redirectToInvoiceInBasicData = ({ id }) => { +const redirectToInvoiceInBasicData = (__, { id }) => { router.push({ name: 'InvoiceInBasicData', params: { id } }); }; From ebbeea0eff19720bae3aff823304817aac8363d1 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 6 Jun 2024 10:28:41 +0200 Subject: [PATCH 2/4] fix: refs #6942 e2e test --- test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js index 77a11969b..9b76339b3 100644 --- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js @@ -12,8 +12,7 @@ describe('InvoiceInBasicData', () => { }); it('should edit the provideer and supplier ref', () => { - cy.selectOption(firstFormSelect, 'Bros'); - cy.get('[title="Reset"]').click(); + cy.selectOption(firstFormSelect, 'Plants'); cy.get(formInputs).eq(1).type('{selectall}4739'); cy.saveCard(); From 209d5bd13e6bde2e368a573b128569d967fc6d43 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 6 Jun 2024 12:09:56 +0200 Subject: [PATCH 3/4] fix: refs #6942 rollback --- test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js index 9b76339b3..77a11969b 100644 --- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js @@ -12,7 +12,8 @@ describe('InvoiceInBasicData', () => { }); it('should edit the provideer and supplier ref', () => { - cy.selectOption(firstFormSelect, 'Plants'); + cy.selectOption(firstFormSelect, 'Bros'); + cy.get('[title="Reset"]').click(); cy.get(formInputs).eq(1).type('{selectall}4739'); cy.saveCard(); From 5d041e2d0314a3e90741b82a80994adb675d6cfb Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 6 Jun 2024 12:14:00 +0200 Subject: [PATCH 4/4] fix: refs #6942 fix emit on reset --- src/components/FormModel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index f88bf47c4..564fba05c 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -212,7 +212,7 @@ async function saveAndGo() { } function reset() { - updateAndEmit(originalData.value, 'onFetch'); + updateAndEmit('onFetch', originalData.value); if ($props.observeFormChanges) { hasChanges.value = false; isResetting.value = true;