Fix issue where the telephone field placeholders weren't localized

This commit is contained in:
Quincy Morgan
2020-05-29 10:57:17 -04:00
parent 2d02d452a9
commit b3ece74807
+15 -8
View File
@@ -28,7 +28,10 @@ export function uiFieldText(field, context) {
if (field.type === 'tel') {
fileFetcher.get('phone_formats')
.then(function(d) { _phoneFormats = d; })
.then(function(d) {
_phoneFormats = d;
updatePhonePlaceholder();
})
.catch(function() { /* ignore */ });
}
@@ -67,13 +70,7 @@ export function uiFieldText(field, context) {
if (field.type === 'tel') {
var extent = combinedEntityExtent();
var countryCode = extent && countryCoder.iso1A2Code(extent.center());
var format = countryCode && _phoneFormats[countryCode.toLowerCase()];
if (format) {
wrap.selectAll('input')
.attr('placeholder', format);
}
updatePhonePlaceholder();
} else if (field.type === 'number') {
var rtl = (localizer.textDirection() === 'rtl');
@@ -136,6 +133,16 @@ export function uiFieldText(field, context) {
}
function updatePhonePlaceholder() {
if (input.empty() || !Object.keys(_phoneFormats).length) return;
var extent = combinedEntityExtent();
var countryCode = extent && countryCoder.iso1A2Code(extent.center());
var format = countryCode && _phoneFormats[countryCode.toLowerCase()];
if (format) input.attr('placeholder', format);
}
function validIdentifierValueForLink() {
if (field.type === 'identifier' && field.pattern) {
var value = utilGetSetValue(input).trim().split(';')[0];