misc: look for address details in more attributes (#43446)

This commit is contained in:
Frédéric Péters 2020-05-29 09:33:54 +02:00
parent 66bcdf7250
commit 949cfce3b4
1 changed files with 17 additions and 7 deletions

View File

@ -59,16 +59,26 @@ function geoloc_prefill(element_type, element_value)
var data = $('.JsonpSingleSelectWidget.template-address select').select2('data');
if (data) {
var number_and_street = null;
if (data[0].address.house_number && data[0].address.road) {
number_and_street = data[0].address.house_number + ' ' + data[0].address.road;
var address = undefined;
if (typeof data[0].address == "object") {
address = data[0].address;
} else {
number_and_street = data[0].address.road;
address = data[0];
}
var road = address.road || address.nom_rue;
var house_number = address.house_number || address.numero;
var city = address.city || address.nom_commune;
var postcode = address.postcode || address.code_postal;
if (house_number && road) {
number_and_street = house_number + ' ' + road;
} else {
number_and_street = road;
}
geoloc_prefill('number-and-street', number_and_street);
geoloc_prefill('house', data[0].address.house_number);
geoloc_prefill('road', data[0].address.road);
geoloc_prefill('city', data[0].address.city);
geoloc_prefill('postcode', data[0].address.postcode);
geoloc_prefill('house', house_number);
geoloc_prefill('road', road);
geoloc_prefill('city', city);
geoloc_prefill('postcode', postcode);
}
});
if ($('.qommon-map').length == 0 && $('.JsonpSingleSelectWidget.template-address').length == 0) {