diff --git a/.eslintrc.js b/.eslintrc.js index c8bdecb1a..1d09a896f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,7 +58,7 @@ module.exports = { rules: { 'prefer-promise-reject-errors': 'off', 'no-unused-vars': 'warn', - + "vue/no-multiple-template-root": "off" , // allow debugger during development only 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', }, diff --git a/Jenkinsfile b/Jenkinsfile index 437332c4e..9dd72ccc3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,4 +96,4 @@ pipeline { } } } -} \ No newline at end of file +} diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue index f4f5fef7d..2a1385945 100644 --- a/src/components/CreateBankEntityForm.vue +++ b/src/components/CreateBankEntityForm.vue @@ -7,6 +7,13 @@ import FetchData from 'components/FetchData.vue'; import VnRow from 'components/ui/VnRow.vue'; import FormModelPopup from './FormModelPopup.vue'; +const props = defineProps({ + showEntityField: { + type: Boolean, + default: true, + }, +}); + const emit = defineEmits(['onDataSaved']); const { t } = useI18n(); @@ -73,7 +80,7 @@ const onDataSaved = (data) => { :rules="validate('bankEntity.countryFk')" /> -
+
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 3504445f8..ccffb2ec2 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -28,16 +28,24 @@ const countriesOptions = ref([]); const provincesOptions = ref([]); const townsLocationOptions = ref([]); -const onDataSaved = () => { - emit('onDataSaved'); +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 () => { > @@ -131,7 +141,7 @@ const onProvinceCreated = async () => { es: New postcode: Nuevo código postal Please, ensure you put the correct data!: ¡Por favor, asegúrese de poner los datos correctos! - City: Ciudad + City: Población Province: Provincia Country: País Postcode: Código postal 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/components/CrudModel.vue b/src/components/CrudModel.vue index 75353a35a..17fc8fc4a 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -225,15 +225,19 @@ function getDifferences(obj1, obj2) { delete obj2.$index; for (let key in obj1) { - if (obj2[key] && obj1[key] !== obj2[key]) { + if (obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) { diff[key] = obj2[key]; } } for (let key in obj2) { - if (obj1[key] === undefined || obj1[key] !== obj2[key]) { + if ( + obj1[key] === undefined || + JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key]) + ) { diff[key] = obj2[key]; } } + return diff; } diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index a5560dfc0..a7e820afa 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -128,13 +128,14 @@ async function save() { try { const body = $props.mapper ? $props.mapper(formData.value) : formData.value; + let response if ($props.urlCreate) { - await axios.post($props.urlCreate, body); + response = await axios.post($props.urlCreate, body); notify('globals.dataCreated', 'positive'); } else { - await axios.patch($props.urlUpdate || $props.url, body); + response = await axios.patch($props.urlUpdate || $props.url, body); } - emit('onDataSaved', formData.value); + emit('onDataSaved', formData.value, response); originalData.value = JSON.parse(JSON.stringify(formData.value)); hasChanges.value = false; } catch (err) { @@ -176,13 +177,6 @@ watch(formUrl, async () => { });