Merge branch 'fix-localized-field-hidden' into develop

This commit is contained in:
Martin Raifer
2024-07-16 17:08:08 +02:00
3 changed files with 15 additions and 1 deletions
+10
View File
@@ -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;
});
}
+2 -1
View File
@@ -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)) {