From b81162c1616e0b5c8f7a6b09993e33ef60f2e852 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 28 Mar 2025 09:24:56 +0100 Subject: [PATCH 1/4] feat: refs #7701 form model use url --- src/components/FormModel.vue | 32 ++++++++++++++++++++++++++++++ src/components/VnTable/VnTable.vue | 15 +++++++------- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c4d9a4149..1222c7bec 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -22,6 +22,7 @@ const { t } = useI18n(); const { validate } = useValidator(); const { notify } = useNotify(); const route = useRoute(); +const router = useRouter(); const myForm = ref(null); const attrs = useAttrs(); const $props = defineProps({ @@ -100,6 +101,10 @@ const $props = defineProps({ type: Function, default: () => {}, }, + searchUrl: { + type: [String, Boolean], + default: 'form', + }, }); const emit = defineEmits(['onFetch', 'onDataSaved']); const modelValue = computed( @@ -133,6 +138,11 @@ const defaultButtons = computed(() => ({ })); onMounted(async () => { + const urlInitalData = + $props.searchUrl && JSON.parse(route?.query[$props.searchUrl] ?? '{}'); + originalData.value = JSON.parse( + JSON.stringify(urlInitalData ?? $props.formInitialData ?? {}), + ); nextTick(() => (componentIsRendered.value = true)); // Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla @@ -181,6 +191,28 @@ watch( }, ); +watch( + () => formData.value, + async (newData, oldData) => { + // console.log('Form data changed:', newData); + // console.log('formData: ', formData.value); + if (JSON.stringify(newData) === JSON.stringify(oldData)) return; + // console.log('Current route query:', route.query); + if (!$props.searchUrl) return; + if (!newData) return; + // console.log('sigue'); + const urlParams = JSON.stringify(newData); + await nextTick(); + router.replace({ + query: { + ...route.query, + createForm: urlParams, + }, + }); + }, + { deep: true }, +); + onBeforeRouteLeave((to, from, next) => { if (hasChanges.value && $props.observeFormChanges) quasar.dialog({ diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index e214770d2..88a983f98 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -206,13 +206,13 @@ onMounted(async () => { ...['tableActions'], ]; createForm.value = $props.create; - if ($props.create && route?.query?.createForm) { - showForm.value = true; - createForm.value = { - ...createForm.value, - ...{ formInitialData: JSON.parse(route?.query?.createForm) }, - }; - } + // if ($props.create && route?.query?.createForm) { + // showForm.value = true; + // createForm.value = { + // ...createForm.value, + // ...{ formInitialData: JSON.parse(route?.query?.createForm) }, + // }; + // } }); onUnmounted(async () => { @@ -1035,6 +1035,7 @@ const rowCtrlClickFunction = computed(() => { transition-hide="scale" :full-width="createComplement?.isFullWidth ?? false" data-cy="vn-table-create-dialog" + persistent > Date: Mon, 7 Apr 2025 09:18:41 +0200 Subject: [PATCH 2/4] refactor: refs #7701 wip dialogs not opening at first click --- src/pages/Entry/EntryStockBought.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/Entry/EntryStockBought.vue b/src/pages/Entry/EntryStockBought.vue index 9e97e2ad5..f74ba1769 100644 --- a/src/pages/Entry/EntryStockBought.vue +++ b/src/pages/Entry/EntryStockBought.vue @@ -204,7 +204,9 @@ async function beforeSave(data, getChanges) { - + + Date: Fri, 11 Apr 2025 06:24:40 +0200 Subject: [PATCH 3/4] feat: refs #7701 wip FormModel changes --- src/boot/defaults/qDialog.js | 4 ++++ src/boot/quasar.defaults.js | 1 + src/components/FormModel.vue | 4 ---- test/cypress/integration/client/clientWebAccess.spec.js | 2 ++ test/cypress/integration/item/itemBotanical.spec.js | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 src/boot/defaults/qDialog.js diff --git a/src/boot/defaults/qDialog.js b/src/boot/defaults/qDialog.js new file mode 100644 index 000000000..c865f0acd --- /dev/null +++ b/src/boot/defaults/qDialog.js @@ -0,0 +1,4 @@ +import setDefault from './setDefault'; +import { QDialog } from 'quasar'; + +setDefault(QDialog, 'noRouteDismiss', true); diff --git a/src/boot/quasar.defaults.js b/src/boot/quasar.defaults.js index 9638e2057..773058e41 100644 --- a/src/boot/quasar.defaults.js +++ b/src/boot/quasar.defaults.js @@ -1,3 +1,4 @@ export * from './defaults/qTable'; export * from './defaults/qInput'; export * from './defaults/qSelect'; +export * from './defaults/qDialog'; diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 1222c7bec..378ab334c 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -194,13 +194,9 @@ watch( watch( () => formData.value, async (newData, oldData) => { - // console.log('Form data changed:', newData); - // console.log('formData: ', formData.value); if (JSON.stringify(newData) === JSON.stringify(oldData)) return; - // console.log('Current route query:', route.query); if (!$props.searchUrl) return; if (!newData) return; - // console.log('sigue'); const urlParams = JSON.stringify(newData); await nextTick(); router.replace({ diff --git a/test/cypress/integration/client/clientWebAccess.spec.js b/test/cypress/integration/client/clientWebAccess.spec.js index 970aab71c..b883665f7 100644 --- a/test/cypress/integration/client/clientWebAccess.spec.js +++ b/test/cypress/integration/client/clientWebAccess.spec.js @@ -4,6 +4,8 @@ describe('Client web-access', () => { cy.viewport(1280, 720); cy.login('developer'); }); + + //falla it('Should test buttons ', () => { cy.visit('#/customer/1101/web-access'); cy.get('.q-page').should('be.visible'); diff --git a/test/cypress/integration/item/itemBotanical.spec.js b/test/cypress/integration/item/itemBotanical.spec.js index 6105ef179..d70b8af85 100644 --- a/test/cypress/integration/item/itemBotanical.spec.js +++ b/test/cypress/integration/item/itemBotanical.spec.js @@ -13,6 +13,7 @@ describe('Item botanical', () => { cy.checkNotification('Data saved'); }); + //falla it('should create a new Genus', () => { cy.dataCy('Genus_icon').click(); cy.dataCy('Latin genus name_input').type('Test'); @@ -20,6 +21,7 @@ describe('Item botanical', () => { cy.checkNotification('Data created'); }); + //falla it('should create a new specie', () => { cy.dataCy('Species_icon').click(); cy.dataCy('Latin species name_input').type('Test specie'); -- 2.40.1 From 20674e90b169c454bfc873a7a22a5707e2218c2d Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Apr 2025 16:06:37 +0200 Subject: [PATCH 4/4] refactor: refs #7701 deleted code --- src/components/VnTable/VnTable.vue | 8 -------- src/pages/Entry/EntryStockBought.vue | 4 +--- test/cypress/integration/item/itemSummary.spec.js | 1 + 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 624e044ae..c5f2a042b 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -208,13 +208,6 @@ onMounted(async () => { ...['tableActions'], ]; createForm.value = $props.create; - // if ($props.create && route?.query?.createForm) { - // showForm.value = true; - // createForm.value = { - // ...createForm.value, - // ...{ formInitialData: JSON.parse(route?.query?.createForm) }, - // }; - // } }); onUnmounted(async () => { @@ -1038,7 +1031,6 @@ const rowCtrlClickFunction = computed(() => { transition-hide="scale" :full-width="createComplement?.isFullWidth ?? false" data-cy="vn-table-create-dialog" - persistent > - - + { cy.dataCy('itemTags').should('be.visible'); }); + //falla it('should regularize stock', () => { cy.dataCy('descriptor-more-opts').click(); cy.get('.q-menu > .q-list > :nth-child(1) > .q-item__section').click(); -- 2.40.1