diff --git a/src/components/CreateNewCityForm.vue b/src/components/CreateNewCityForm.vue index 9a7d8666c..85d13beb1 100644 --- a/src/components/CreateNewCityForm.vue +++ b/src/components/CreateNewCityForm.vue @@ -1,35 +1,42 @@ - (provincesOptions = data)" - auto-load - url="Provinces" - /> { - + diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index dc8027989..99cba5360 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -63,17 +63,27 @@ function setTown(newTown, data) { } async function setProvince(id, data) { - await provincesFetchDataRef.value.fetch(); const newProvince = provincesOptions.value.find((province) => province.id == id); if (!newProvince) return; data.countryFk = newProvince.countryFk; } +async function onProvinceCreated(data) { + await provincesFetchDataRef.value.fetch({ + where: { countryFk: postcodeFormData.countryFk }, + }); + postcodeFormData.provinceFk.value = data.id; +} + watch( () => [postcodeFormData.countryFk], - async (newCountryFk) => { - if (newCountryFk) { + async (newCountryFk, oldValueFk) => { + if (!!oldValueFk[0] && newCountryFk[0] !== oldValueFk[0]) { + postcodeFormData.provinceFk = null; + postcodeFormData.townFk = null; + } + if ((newCountryFk, newCountryFk !== postcodeFormData.countryFk)) { await provincesFetchDataRef.value.fetch({ where: { countryFk: newCountryFk[0], @@ -93,7 +103,7 @@ watch( watch( () => postcodeFormData.provinceFk, async (newProvinceFk) => { - if (newProvinceFk) { + if (newProvinceFk[0] && newProvinceFk[0] !== postcodeFormData.provinceFk) { await townsFetchDataRef.value.fetch({ where: { provinceFk: newProvinceFk[0] }, }); @@ -140,10 +150,12 @@ async function handleCountries(data) { :label="t('Postcode')" v-model="data.code" :rules="validate('postcode.code')" + clearable /> setTown(value, data)" + :tooltip="t('Create city')" v-model="data.townFk" :options="townsOptions" option-label="name" @@ -151,7 +163,7 @@ async function handleCountries(data) { :rules="validate('postcode.city')" :acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]" :emit-value="false" - clearable + :clearable="true" > @@ -166,6 +178,9 @@ async function handleCountries(data) { onCityCreated(requestResponse, data) @@ -176,9 +191,13 @@ async function handleCountries(data) { setProvince(value, data)" v-model="data.provinceFk" + :clearable="true" + :provinces="provincesOptions" + @on-province-created="onProvinceCreated" /> es: New postcode: Nuevo código postal + Create city: Crear población Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos! City: Población Province: Provincia diff --git a/src/components/CreateNewProvinceForm.vue b/src/components/CreateNewProvinceForm.vue index e32684a98..4c1d96930 100644 --- a/src/components/CreateNewProvinceForm.vue +++ b/src/components/CreateNewProvinceForm.vue @@ -16,7 +16,16 @@ const provinceFormData = reactive({ name: null, autonomyFk: null, }); - +const $props = defineProps({ + countryFk: { + type: Number, + default: null, + }, + provinces: { + type: Array, + default: () => [], + }, +}); const autonomiesOptions = ref([]); const onDataSaved = (dataSaved, requestResponse) => { @@ -31,6 +40,11 @@ const onDataSaved = (dataSaved, requestResponse) => { (autonomiesOptions = data)" auto-load + :filter="{ + where: { + countryFk: $props.countryFk, + }, + }" url="Autonomies/location" /> await provincesFetchDataRef.value.fetch()); const $props = defineProps({ countryFk: { type: Number, default: null, }, + provinceSelected: { + type: Number, + default: null, + }, + provinces: { + type: Array, + default: () => [], + }, }); +const provinceFk = defineModel({ type: Number, default: null }); + const { validate } = useValidator(); const { t } = useI18n(); -const provincesOptions = ref(); +const provincesOptions = ref($props.provinces); +provinceFk.value = $props.provinceSelected; const provincesFetchDataRef = ref(); async function onProvinceCreated(_, data) { @@ -27,16 +36,6 @@ async function onProvinceCreated(_, data) { provinceFk.value = data.id; emit('onProvinceCreated', data); } -watch( - () => $props.countryFk, - async (newProvinceFk) => { - if (newProvinceFk) { - await provincesFetchDataRef.value.fetch({ - where: { countryFk: newProvinceFk }, - }); - } - } -); async function handleProvinces(data) { provincesOptions.value = data; } @@ -45,14 +44,19 @@ async function handleProvinces(data) { - + es: Province: Provincia + Create province: Crear provincia diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index f389ca842..d93ad7465 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -140,12 +140,6 @@ const mixinRules = [ .q-field__control { height: unset; } -.q-field__control.relative-position.row.no-wrap - > .q-field__control-container - > input.q-field__native - ~ div.q-field__label { - height: 41px; -} .q-field--labeled { .q-field__native, diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index 806aa4ac2..5f94c466a 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -73,6 +73,7 @@ const handleModelValue = (data) => { v-bind="$attrs" clearable :emit-value="false" + :tooltip="t('Create new location')" > { en: search_by_postalcode: Search by postalcode, town, province or country + Create new location: Create new location es: Location: Ubicación + Create new location: Crear nueva ubicación search_by_postalcode: Buscar por código postal, ciudad o país diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index d87f6c402..d5de60f16 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -53,7 +53,7 @@ const tableRef = ref([]); watch( () => route.params.id, - async () => await getSales() + () => tableRef.value.reload() ); const columns = computed(() => [ @@ -161,15 +161,6 @@ const onSalesFetched = (salesData) => { for (let sale of salesData) sale.amount = getSaleTotal(sale); }; -const getSales = async () => { - try { - const { data } = await axios.get(`Tickets/${route.params.id}/getSales`); - onSalesFetched(data); - } catch (err) { - console.error('Error fetching sales', err); - } -}; - const getSaleTotal = (sale) => { if (sale.quantity == null || sale.price == null) return null; @@ -181,7 +172,7 @@ const getSaleTotal = (sale) => { const resetChanges = async () => { arrayData.fetch({ append: false }); - getSales(); + tableRef.value.reload(); }; const updateQuantity = async (sale) => { @@ -434,7 +425,6 @@ const setTransferParams = async () => { onMounted(async () => { stateStore.rightDrawer = true; getConfig(); - getSales(); getItems(); }); @@ -623,6 +613,7 @@ watch( :column-search="false" :disable-option="{ card: true }" auto-load + @on-fetch="onSalesFetched" :create="{ onDataSaved: handleOnDataSave, }" diff --git a/src/pages/Zone/Card/ZoneEvents.vue b/src/pages/Zone/Card/ZoneEvents.vue index 32a7db4c4..3452849bc 100644 --- a/src/pages/Zone/Card/ZoneEvents.vue +++ b/src/pages/Zone/Card/ZoneEvents.vue @@ -44,23 +44,6 @@ onUnmounted(() => (stateStore.rightDrawer = false)); - - - - - - {{ t('globals.collapseMenu') }} - - - - - import { onMounted, ref, computed, watch, onUnmounted } from 'vue'; import { useRoute } from 'vue-router'; - +import VnInput from 'src/components/common/VnInput.vue'; import { useState } from 'src/composables/useState'; import axios from 'axios'; import { useArrayData } from 'composables/useArrayData'; @@ -144,7 +144,8 @@ watch(storeData, async (val) => { }); const reFetch = async () => { - await arrayData.fetch({ append: false }); + const { data } = await arrayData.fetch({ append: false }); + nodes.value = data; }; onMounted(async () => { @@ -182,6 +183,16 @@ onUnmounted(() => { + + + + + { `${createForm.prefix} > :nth-child(4) > .q-field:nth-child(3)> ${createForm.sufix}` ).should('have.length', 1); }); + it('should pass selected country', () => { + // Select a country + const country = 'Ecuador'; + const province = 'Province five'; + cy.selectOption( + `${createForm.prefix} > :nth-child(5) > .q-field:nth-child(5)> ${createForm.sufix}`, + country + ); + cy.selectOption( + `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, + province + ); + cy.get( + `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) > .q-icon` + ).click(); + cy.get( + `#q-portal--dialog--4 > .q-dialog > ${createForm.prefix} > .vn-row > .q-select > ${createForm.sufix} > :nth-child(1) input` + ).should('have.value', province); + }); }); describe('Worker Create', () => { beforeEach(() => {