Remove lodash includes and reduce from address.js

(re #6087)
This commit is contained in:
Bryan Housel
2019-03-26 12:20:58 -04:00
parent 5b9707004f
commit 33a40f59eb
+13 -7
View File
@@ -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);
})