0
0
Fork 0

refs #6280 feat: handle option selected from VnLocation

This commit is contained in:
Javier Segarra 2024-01-15 09:14:42 +01:00
parent b6a03e6a9f
commit 20835471a3
2 changed files with 15 additions and 7 deletions

View File

@ -98,9 +98,8 @@ function showLabel(data){
v-model="value"
:options="postcodesOptions"
:label="t('Location')"
option-value="geoFk"
:option-label="showLabel"
:placeholder="t('Min. 3 char')"
:placeholder="t('Search by postalCode or town (at least 3 characters')"
v-bind="$attrs"
emit-value
map-options
@ -138,4 +137,5 @@ function showLabel(data){
<i18n>
es:
Location: Ubicación
Search by postalCode or town (at least 3 characters): Buscar por código postal o nombre ( al menos 3 letras)
</i18n>

View File

@ -36,9 +36,13 @@ const provincesLocationOptions = ref([]);
const countriesOptions = ref([]);
const postcodesOptions = ref([]);
const onPostcodeCreated = async () => {
postcodeFetchDataRef.value.fetch();
};
function handleLocation(data, { city, postcode, provinceFk, countryFk }) {
data.postcode = postcode;
data.city = city;
data.provinceFk = provinceFk;
data.countryFk = countryFk;
}
</script>
<template>
@ -133,9 +137,13 @@ const onPostcodeCreated = async () => {
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnLocation
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
v-model="data.location"
@update:model-value="(data)=> console.log(data)"
@update:model-value="
(location) => handleLocation(data, location)
"
>
</VnLocation>
</div>