From 2302e22f1115a9b5d057e2a7e47b44d6b630968c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 30 Sep 2024 15:00:05 +0200 Subject: [PATCH] fix: solve conflicts from master to test --- src/components/VnTable/VnTable.vue | 4 +- src/components/common/VnLocation.vue | 43 +++++++++++-- src/i18n/locale/en.yml | 2 +- src/i18n/locale/es.yml | 2 +- .../Customer/Card/CustomerFiscalData.vue | 1 + src/pages/Customer/Card/CustomerSummary.vue | 1 + src/pages/Customer/CustomerList.vue | 3 +- .../Customer/Defaulter/CustomerDefaulter.vue | 7 -- src/pages/Item/ItemFixedPrice.vue | 20 +++--- .../Supplier/Card/SupplierAddressesCreate.vue | 1 + src/pages/Ticket/Card/TicketSummary.vue | 64 +++++++++---------- src/pages/Worker/WorkerList.vue | 1 + 12 files changed, 86 insertions(+), 63 deletions(-) diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 9dcbc5542..3ed741ac4 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -310,8 +310,8 @@ defineExpose({ params, }); -function handleOnDataSaved(_) { - if (_.onDataSaved) _.onDataSaved(this); +function handleOnDataSaved(_, res) { + if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value }); else $props.create.onDataSaved(_); } diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index e5ed14a40..c1b921915 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -12,17 +12,48 @@ const props = defineProps({ default: null, }, }); +const formatLocation = (obj, properties) => { + const parts = properties.map((prop) => { + if (typeof prop === 'string') { + return obj[prop]; + } else if (typeof prop === 'function') { + return prop(obj); + } + return null; + }); + + const filteredParts = parts.filter( + (part) => part !== null && part !== undefined && part !== '' + ); + + return filteredParts.join(', '); +}; + +const locationProperties = [ + 'postcode', + (obj) => + obj.city + ? `${obj.city}${obj.province?.name ? `(${obj.province.name})` : ''}` + : null, + (obj) => obj.country?.name, +]; + const modelValue = ref( - props.location - ? `${props.location?.postcode}, ${props.location?.city}(${props.location?.province?.name}), ${props.location?.country?.name}` - : null + props.location ? formatLocation(props.location, locationProperties) : null ); -function showLabel(data) { - return `${data.code}, ${data.town}(${data.province}), ${data.country}`; -} + const handleModelValue = (data) => { emit('update:model-value', data); }; + +function showLabel(data) { + const dataProperties = [ + 'code', + (obj) => (obj.town ? `${obj.town}(${obj.province})` : null), + 'country', + ]; + return formatLocation(data, dataProperties); +}