From 4bf16da814579840108b688cd0c22b6ab904b15d Mon Sep 17 00:00:00 2001 From: wbuezas Date: Fri, 12 Jan 2024 09:49:34 -0300 Subject: [PATCH] Improve autocompletion --- src/components/CreateNewCityForm.vue | 4 ++-- src/components/CreateNewPostcodeForm.vue | 18 ++++++++++++++---- src/components/CreateNewProvinceForm.vue | 4 ++-- src/pages/Customer/Card/CustomerFiscalData.vue | 7 +++++-- src/pages/Customer/CustomerCreate.vue | 5 ++++- src/pages/Supplier/Card/SupplierFiscalData.vue | 13 ++++++++----- src/pages/Worker/WorkerCreate.vue | 5 ++++- 7 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/components/CreateNewCityForm.vue b/src/components/CreateNewCityForm.vue index ee842e86f..7326ea7a5 100644 --- a/src/components/CreateNewCityForm.vue +++ b/src/components/CreateNewCityForm.vue @@ -19,8 +19,8 @@ const cityFormData = reactive({ const provincesOptions = ref([]); -const onDataSaved = () => { - emit('onDataSaved'); +const onDataSaved = (dataSaved) => { + emit('onDataSaved', dataSaved); }; diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index 40efa0789..ccffb2ec2 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -32,12 +32,20 @@ const onDataSaved = (dataSaved) => { emit('onDataSaved', dataSaved); }; -const onCityCreated = async () => { +const onCityCreated = async ({ name, provinceFk }, formData) => { await townsFetchDataRef.value.fetch(); + formData.townFk = townsLocationOptions.value.find((town) => town.name === name).id; + formData.provinceFk = provinceFk; + formData.countryFk = provincesOptions.value.find( + (province) => province.id === provinceFk + ).countryFk; }; -const onProvinceCreated = async () => { +const onProvinceCreated = async ({ name }, formData) => { await provincesFetchDataRef.value.fetch(); + formData.provinceFk = provincesOptions.value.find( + (province) => province.name === name + ).id; }; @@ -88,7 +96,9 @@ const onProvinceCreated = async () => { :roles-allowed-to-create="['deliveryAssistant']" > @@ -107,7 +117,7 @@ const onProvinceCreated = async () => { > diff --git a/src/components/CreateNewProvinceForm.vue b/src/components/CreateNewProvinceForm.vue index 0f88952ea..b972db2c9 100644 --- a/src/components/CreateNewProvinceForm.vue +++ b/src/components/CreateNewProvinceForm.vue @@ -19,8 +19,8 @@ const provinceFormData = reactive({ const autonomiesOptions = ref([]); -const onDataSaved = () => { - emit('onDataSaved'); +const onDataSaved = (dataSaved) => { + emit('onDataSaved', dataSaved); }; diff --git a/src/pages/Customer/Card/CustomerFiscalData.vue b/src/pages/Customer/Card/CustomerFiscalData.vue index e7e626a99..0edcc3c07 100644 --- a/src/pages/Customer/Card/CustomerFiscalData.vue +++ b/src/pages/Customer/Card/CustomerFiscalData.vue @@ -14,16 +14,18 @@ import VnSelectCreate from 'src/components/common/VnSelectCreate.vue'; const { t } = useI18n(); const route = useRoute(); +const townsFetchDataRef = ref(null); +const postcodeFetchDataRef = ref(null); const typesTaxes = ref([]); const typesTransactions = ref([]); -const postcodeFetchDataRef = ref(null); const citiesLocationOptions = ref([]); const provincesLocationOptions = ref([]); const countriesOptions = ref([]); const postcodesOptions = ref([]); const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formData) => { - postcodeFetchDataRef.value.fetch(); + await postcodeFetchDataRef.value.fetch(); + await townsFetchDataRef.value.fetch(); formData.postcode = code; formData.provinceFk = provinceFk; formData.city = citiesLocationOptions.value.find((town) => town.id === townFk).name; @@ -39,6 +41,7 @@ const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formDa url="SageTransactionTypes" /> { - postcodeFetchDataRef.value.fetch(); + await postcodeFetchDataRef.value.fetch(); + await townsFetchDataRef.value.fetch(); formData.postcode = code; formData.provinceFk = provinceFk; formData.city = citiesLocationOptions.value.find((town) => town.id === townFk).name; @@ -64,6 +66,7 @@ const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formDa url="BusinessTypes" /> { - postcodeFetchDataRef.value.fetch(); - formData.postcode = code; + await postcodeFetchDataRef.value.fetch(); + await townsFetchDataRef.value.fetch(); + formData.postCode = code; formData.provinceFk = provinceFk; formData.city = townsLocationOptions.value.find((town) => town.id === townFk).name; formData.countryFk = countryFk; @@ -60,6 +62,7 @@ const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formDa auto-load />
diff --git a/src/pages/Worker/WorkerCreate.vue b/src/pages/Worker/WorkerCreate.vue index eb9dc70f6..91d4d454b 100644 --- a/src/pages/Worker/WorkerCreate.vue +++ b/src/pages/Worker/WorkerCreate.vue @@ -50,6 +50,7 @@ const newWorkerForm = ref({ }); const postcodeFetchDataRef = ref(null); +const townsFetchDataRef = ref(null); const provincesOptions = ref([]); const townsOptions = ref([]); const companiesOptions = ref([]); @@ -67,7 +68,8 @@ const onBankEntityCreated = (data) => { }; const onPostcodeCreated = async ({ code, provinceFk, townFk }, formData) => { - postcodeFetchDataRef.value.fetch(); + await postcodeFetchDataRef.value.fetch(); + await townsFetchDataRef.value.fetch(); formData.postcode = code; formData.provinceFk = provinceFk; formData.city = townsOptions.value.find((town) => town.id === townFk).name; @@ -99,6 +101,7 @@ onMounted(async () => { auto-load />