From 97ec2fabc550e53acf71a3f3eafbde7d3d1bc085 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 5 Mar 2025 15:37:35 -0300 Subject: [PATCH] Improvements --- package.json | 2 +- src/components/common/FormModel.vue | 12 +- src/components/common/VnInput.vue | 171 +++++++++++++++++++++------ src/components/common/VnSelect.vue | 2 +- src/composables/useRequired.js | 17 +++ src/i18n/ca-ES/index.js | 2 + src/i18n/en-US/index.js | 2 + src/i18n/es-ES/index.js | 2 + src/i18n/fr-FR/index.js | 2 + src/i18n/pt-PT/index.js | 2 + src/pages/Account/AddressDetails.vue | 6 + 11 files changed, 179 insertions(+), 41 deletions(-) create mode 100644 src/composables/useRequired.js diff --git a/package.json b/package.json index 64004f37..da3b8435 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "salix": "cd ../salix && gulp back", "db": "cd ../salix && gulp docker", "cy:open": "npm run db && cypress open", - "test:e2e": "npm run db && cypress run", + "test:e2e": "npm run db && cypress run --headed --config video=false", "test:unit": "vitest", "build": "rm -rf dist/ ; quasar build", "clean": "rm -rf dist/", diff --git a/src/components/common/FormModel.vue b/src/components/common/FormModel.vue index 7f0bfa2e..be7ae1c4 100644 --- a/src/components/common/FormModel.vue +++ b/src/components/common/FormModel.vue @@ -81,7 +81,7 @@ const { isHeaderMounted } = storeToRefs(appStore); const isLoading = ref(false); const formData = ref({}); -const addressFormRef = ref(null); +const formModelRef = ref(null); const hasChanges = ref(!props.observeFormChanges); const isResetting = ref(false); const originalData = ref(null); @@ -119,6 +119,7 @@ onMounted(async () => { ); } }); + async function fetch() { try { let { data } = await api.get(props.url, { @@ -133,9 +134,12 @@ async function fetch() { } async function submit() { - console.log('submit: '); if (props.observeFormChanges && !hasChanges.value) - return notify('globals.noChanges', 'negative'); + return notify('noChanges', 'negative'); + + const isValid = await formModelRef.value.validate(); + console.log('isValid', isValid); + if (!isValid) return; isLoading.value = true; try { @@ -167,7 +171,7 @@ defineExpose({ diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 508ce132..7dcf1164 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -1,15 +1,20 @@