mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
address: fix bug when editing address: update localisation and addressreferenceId + better update of the map in edition
This commit is contained in:
parent
f14c915502
commit
76549581e6
@ -628,6 +628,10 @@ export default {
|
|||||||
newAddress = Object.assign(newAddress, {
|
newAddress = Object.assign(newAddress, {
|
||||||
'addressReference': this.entity.selected.address.addressReference
|
'addressReference': this.entity.selected.address.addressReference
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
newAddress = Object.assign(newAddress, {
|
||||||
|
'addressReference': null
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.validFrom) {
|
if (this.validFrom) {
|
||||||
|
@ -8,12 +8,15 @@ import L from 'leaflet';
|
|||||||
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
|
|
||||||
let map;
|
|
||||||
let marker;
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddressMap',
|
name: 'AddressMap',
|
||||||
props: ['entity'],
|
props: ['entity'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
map: null,
|
||||||
|
marker: null
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
center() {
|
center() {
|
||||||
return this.entity.selected.addressMap.center;
|
return this.entity.selected.addressMap.center;
|
||||||
@ -21,30 +24,33 @@ export default {
|
|||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
init() {
|
init() {
|
||||||
map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
this.map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
||||||
|
|
||||||
map.scrollWheelZoom.disable();
|
this.map.scrollWheelZoom.disable();
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}).addTo(this.map);
|
||||||
|
|
||||||
const markerIcon = L.icon({
|
const markerIcon = L.icon({
|
||||||
iconUrl: markerIconPng,
|
iconUrl: markerIconPng,
|
||||||
iconAnchor: [12, 41],
|
iconAnchor: [12, 41],
|
||||||
});
|
});
|
||||||
|
|
||||||
marker = L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
|
this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon});
|
||||||
|
this.marker.addTo(this.map);
|
||||||
},
|
},
|
||||||
update() {
|
update() {
|
||||||
//console.log('update map with : ', this.address.addressMap.center)
|
//console.log('update map with : ', this.entity.addressMap.center)
|
||||||
marker.setLatLng(this.entity.addressMap.center);
|
if (this.marker && this.entity.addressMap.center) {
|
||||||
map.setView(this.entity.addressMap.center, 15);
|
this.marker.setLatLng(this.entity.addressMap.center);
|
||||||
|
this.map.setView(this.entity.addressMap.center, 15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
this.init()
|
this.init();
|
||||||
|
this.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -106,6 +106,9 @@ export default {
|
|||||||
this.$emit('getReferenceAddresses', this.value);
|
this.$emit('getReferenceAddresses', this.value);
|
||||||
if (this.value.center) {
|
if (this.value.center) {
|
||||||
this.updateMapCenter(this.value.center);
|
this.updateMapCenter(this.value.center);
|
||||||
|
if (this.value.center.coordinates) {
|
||||||
|
this.entity.selected.postcode.coordinates = this.value.center.coordinates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -71,6 +71,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
|||||||
'id' => $address->getPostCode()->getId(),
|
'id' => $address->getPostCode()->getId(),
|
||||||
'name' => $address->getPostCode()->getName(),
|
'name' => $address->getPostCode()->getName(),
|
||||||
'code' => $address->getPostCode()->getCode(),
|
'code' => $address->getPostCode()->getCode(),
|
||||||
|
'center' => $address->getPostcode()->getCenter(),
|
||||||
],
|
],
|
||||||
'country' => [
|
'country' => [
|
||||||
'id' => $address->getPostCode()->getCountry()->getId(),
|
'id' => $address->getPostCode()->getCountry()->getId(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user