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/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue new file mode 100644 index 000000000..0b30faaa7 --- /dev/null +++ b/src/components/common/VnLocation.vue @@ -0,0 +1,135 @@ + + + + + +es: + Location: Ubicación + Search by postalcode, town, province or country: Buscar por código postal, ciudad o país + diff --git a/src/components/common/VnSelectFilter.vue b/src/components/common/VnSelectFilter.vue index 244fb50bb..7f10f5efe 100644 --- a/src/components/common/VnSelectFilter.vue +++ b/src/components/common/VnSelectFilter.vue @@ -12,11 +12,11 @@ const $props = defineProps({ default: () => [], }, optionLabel: { - type: String, + type: [String], default: '', }, filterOptions: { - type: Array, + type: [Array], default: () => [], }, isClearable: { @@ -47,6 +47,7 @@ function setOptions(data) { myOptions.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); } + setOptions(options.value); const filter = (val, options) => { const search = val.toString().toLowerCase(); diff --git a/src/pages/Customer/CustomerCreate.vue b/src/pages/Customer/CustomerCreate.vue index 310deb71a..63c90c9df 100644 --- a/src/pages/Customer/CustomerCreate.vue +++ b/src/pages/Customer/CustomerCreate.vue @@ -2,12 +2,11 @@ import { reactive, ref } from 'vue'; import { useI18n } from 'vue-i18n'; -import CustomerCreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue'; import FetchData from 'components/FetchData.vue'; import FormModel from 'components/FormModel.vue'; import VnRow from 'components/ui/VnRow.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; -import VnSelectCreate from 'src/components/common/VnSelectCreate.vue'; +import VnLocation from 'src/components/common/VnLocation.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; const { t } = useI18n(); @@ -29,23 +28,18 @@ const newClientForm = reactive({ isEqualizated: false, }); -const postcodeFetchDataRef = ref(null); -const townsFetchDataRef = ref(null); const workersOptions = ref([]); const businessTypesOptions = ref([]); -const citiesLocationOptions = ref([]); -const provincesLocationOptions = ref([]); -const countriesOptions = ref([]); const postcodesOptions = ref([]); -const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formData) => { - await postcodeFetchDataRef.value.fetch(); - await townsFetchDataRef.value.fetch(); - formData.postcode = code; - formData.provinceFk = provinceFk; - formData.city = citiesLocationOptions.value.find((town) => town.id === townFk).name; - formData.countryFk = countryFk; -}; + +function handleLocation(data, location ) { + const { town, code, provinceFk, countryFk } = location ?? {} + data.postcode = code; + data.city = town; + data.provinceFk = provinceFk; + data.countryFk = countryFk; +}