mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
@@ -1,5 +1,3 @@
|
||||
import _includes from 'lodash-es/includes';
|
||||
import _reduce from 'lodash-es/reduce';
|
||||
import _uniqBy from 'lodash-es/uniqBy';
|
||||
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
@@ -113,10 +111,18 @@ export function uiFieldAddress(field, context) {
|
||||
|
||||
function countryCallback(err, countryCode) {
|
||||
if (err) return;
|
||||
countryCode = countryCode.toLowerCase();
|
||||
|
||||
var addressFormat = dataAddressFormats.find(function (a) {
|
||||
return a && a.countryCodes && _includes(a.countryCodes, countryCode.toLowerCase());
|
||||
}) || dataAddressFormats[0];
|
||||
var addressFormat;
|
||||
for (var i = 0; i < dataAddressFormats.length; i++) {
|
||||
var format = dataAddressFormats[i];
|
||||
if (!format.countryCodes) {
|
||||
addressFormat = format; // choose the default format, keep going
|
||||
} else if (format.countryCodes.indexOf(countryCode) !== -1) {
|
||||
addressFormat = format; // choose the country format, stop here
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var dropdowns = addressFormat.dropdowns || [
|
||||
'city', 'county', 'country', 'district', 'hamlet',
|
||||
@@ -131,7 +137,7 @@ export function uiFieldAddress(field, context) {
|
||||
|
||||
function row(r) {
|
||||
// Normalize widths.
|
||||
var total = _reduce(r, function(sum, key) {
|
||||
var total = r.reduce(function(sum, key) {
|
||||
return sum + (widths[key] || 0.5);
|
||||
}, 0);
|
||||
|
||||
@@ -154,7 +160,7 @@ export function uiFieldAddress(field, context) {
|
||||
.append('input')
|
||||
.property('type', 'text')
|
||||
.attr('placeholder', function (d) {
|
||||
var localkey = d.id + '!' + countryCode.toLowerCase();
|
||||
var localkey = d.id + '!' + countryCode;
|
||||
var tkey = field.strings.placeholders[localkey] ? localkey : d.id;
|
||||
return field.t('placeholders.' + tkey);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user