mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'fix_address' into post-prototypage
This commit is contained in:
commit
b14b27c110
@ -119,15 +119,21 @@ export default {
|
|||||||
let decimal = [];
|
let decimal = [];
|
||||||
substr.forEach((s, i) => { decimal[i] = /^\d+$/.test(s) });
|
substr.forEach((s, i) => { decimal[i] = /^\d+$/.test(s) });
|
||||||
if (decimal[0] === true) {
|
if (decimal[0] === true) {
|
||||||
return { number: substr.shift(),
|
return {
|
||||||
street: substr.join(' ') }
|
number: substr.shift(),
|
||||||
|
street: substr.join(' ')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (decimal[decimal.length - 1] === true) {
|
else if (decimal[decimal.length - 1] === true) {
|
||||||
return { number: substr.pop(),
|
return {
|
||||||
street: substr.join(' ') }
|
number: substr.pop(),
|
||||||
|
street: substr.join(' ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
number: '',
|
||||||
|
street: substr.join(' ')
|
||||||
}
|
}
|
||||||
return { number: '',
|
|
||||||
street: substr.join(' ') }
|
|
||||||
},
|
},
|
||||||
addAddress() {
|
addAddress() {
|
||||||
this.entity.selected.writeNew.address = true;
|
this.entity.selected.writeNew.address = true;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
id="citySelector"
|
id="citySelector"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
|
@search-change="listenInputSearch"
|
||||||
|
ref="citySelector"
|
||||||
@select="selectCity"
|
@select="selectCity"
|
||||||
name="field"
|
name="field"
|
||||||
track-by="id"
|
track-by="id"
|
||||||
@ -18,7 +20,7 @@
|
|||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="custom-postcode row g-1" v-if="writeNewPostcode">
|
<div class="custom-postcode row g-1" v-if="writeNewPostcode || (isEnteredCustomCity && !isCitySelectorOpen)">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
@ -59,6 +61,12 @@ export default {
|
|||||||
writeNewPostcode() {
|
writeNewPostcode() {
|
||||||
return this.entity.selected.writeNew.postcode;
|
return this.entity.selected.writeNew.postcode;
|
||||||
},
|
},
|
||||||
|
isCitySelectorOpen() {
|
||||||
|
return this.$refs.citySelector.$data.isOpen;
|
||||||
|
},
|
||||||
|
isEnteredCustomCity() {
|
||||||
|
return this.$data.value !== null && typeof this.$data.value.text !== 'undefined';
|
||||||
|
},
|
||||||
cities() {
|
cities() {
|
||||||
return this.entity.loaded.cities;
|
return this.entity.loaded.cities;
|
||||||
},
|
},
|
||||||
@ -81,7 +89,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
transName(value) {
|
transName(value) {
|
||||||
return `${value.code}-${value.name}`
|
return (value.code && value.name) ? `${value.code}-${value.name}` : '';
|
||||||
},
|
},
|
||||||
selectCity(value) {
|
selectCity(value) {
|
||||||
this.entity.selected.city = value;
|
this.entity.selected.city = value;
|
||||||
@ -90,6 +98,45 @@ export default {
|
|||||||
this.$emit('getReferenceAddresses', value);
|
this.$emit('getReferenceAddresses', value);
|
||||||
this.focusOnAddress();
|
this.focusOnAddress();
|
||||||
},
|
},
|
||||||
|
listenInputSearch(query) {
|
||||||
|
console.log('listenInputSearch', query, this.isCitySelectorOpen);
|
||||||
|
if (this.isCitySelectorOpen) {
|
||||||
|
this.$data.value = { text: query };
|
||||||
|
} else if (this.isEnteredCustomCity) {
|
||||||
|
let city = this.splitCity(this.$data.value.text);
|
||||||
|
this.$refs.citySelector.currentOptionLabel = '';
|
||||||
|
this.entity.selected.city = city;
|
||||||
|
this.entity.selected.postcode.name = city.name;
|
||||||
|
this.entity.selected.postcode.code = city.code;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
splitCity(city) {
|
||||||
|
let substr = city
|
||||||
|
.split('-')
|
||||||
|
.map(s => s.trim());
|
||||||
|
if (substr.length === 1) {
|
||||||
|
substr = city.split(' ');
|
||||||
|
}
|
||||||
|
console.log('substr', substr);
|
||||||
|
let decimal = [];
|
||||||
|
substr.forEach((s, i) => { decimal[i] = /^\d+$/.test(s) });
|
||||||
|
if (decimal[0] === true) {
|
||||||
|
return {
|
||||||
|
code: substr.shift(),
|
||||||
|
name: substr.join(' ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (decimal[decimal.length - 1] === true) {
|
||||||
|
return {
|
||||||
|
code: substr.pop(),
|
||||||
|
name: substr.join(' ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
code: '',
|
||||||
|
name: substr.join(' ')
|
||||||
|
}
|
||||||
|
},
|
||||||
addPostcode() {
|
addPostcode() {
|
||||||
this.entity.selected.writeNew.postcode = true;
|
this.entity.selected.writeNew.postcode = true;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
focusOnAddress() {
|
focusOnAddress() {
|
||||||
const addressSelector = document.getElementById('addressSelector');
|
const addressSelector = document.getElementById('addressSelector');
|
||||||
addressSelector.focus();
|
if (addressSelector !== null) {
|
||||||
|
addressSelector.focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updateMapCenter(point) {
|
updateMapCenter(point) {
|
||||||
//console.log('point', point);
|
//console.log('point', point);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user