mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Merge branch 'fix-localized-field-hidden' into develop
This commit is contained in:
@@ -8,6 +8,7 @@ import { uiTooltip } from './tooltip';
|
||||
import { geoExtent } from '../geo/extent';
|
||||
import { uiFieldHelp } from './field_help';
|
||||
import { uiFields } from './fields';
|
||||
import { LANGUAGE_SUFFIX_REGEX } from './fields/localized';
|
||||
import { uiTagReference } from './tag_reference';
|
||||
import { utilRebind, utilUniqueDomId } from '../util';
|
||||
|
||||
@@ -97,6 +98,15 @@ export function uiField(context, presetField, entityIDs, options) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (field.type === 'localized') {
|
||||
for (let tagKey in _tags) {
|
||||
// matches for field:<code>, where <code> is a BCP 47 locale code
|
||||
let match = tagKey.match(LANGUAGE_SUFFIX_REGEX);
|
||||
if (match && match[1] === field.key && match[2]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _tags[key] !== undefined;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { uiLengthIndicator } from '../length_indicator';
|
||||
|
||||
var _languagesArray = [];
|
||||
|
||||
export const LANGUAGE_SUFFIX_REGEX = /^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/;
|
||||
|
||||
export function uiFieldLocalized(field, context) {
|
||||
var dispatch = d3_dispatch('change', 'input');
|
||||
@@ -127,7 +128,7 @@ export function uiFieldLocalized(field, context) {
|
||||
// matches for field:<code>, where <code> is a BCP 47 locale code
|
||||
// motivation is to avoid matching on similarly formatted tags that are
|
||||
// not for languages, e.g. name:left, name:source, etc.
|
||||
var m = k.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/);
|
||||
var m = k.match(LANGUAGE_SUFFIX_REGEX);
|
||||
if (m && m[1] === field.key && m[2]) {
|
||||
var item = { lang: m[2], value: tags[k] };
|
||||
if (existingLangs.has(item.lang)) {
|
||||
|
||||
Reference in New Issue
Block a user