From 9576e95d83b6a974b755160fc292ea7a806f1e92 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 23 Jun 2022 10:29:22 +0200 Subject: [PATCH] change label of ui fields from raw html to a callback function fixes #9159 --- modules/presets/field.js | 4 +++- modules/ui/field.js | 2 +- modules/ui/intro/area.js | 8 ++++---- modules/ui/intro/navigation.js | 8 ++++---- modules/ui/sections/preset_fields.js | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/presets/field.js b/modules/presets/field.js index ee81d38a3..5e7a60a73 100644 --- a/modules/presets/field.js +++ b/modules/presets/field.js @@ -26,7 +26,9 @@ export function presetField(fieldID, field) { _this.hasTextForStringId = (scope) => localizer.hasTextForStringId(`_tagging.presets.fields.${fieldID}.${scope}`); _this.title = () => _this.overrideLabel || _this.t('label', { 'default': fieldID }); - _this.label = () => _this.overrideLabel || _this.t.html('label', { 'default': fieldID }); + _this.label = () => _this.overrideLabel ? + selection => selection.text(_this.overrideLabel) : + _this.t.append('label', { 'default': fieldID }); const _placeholder = _this.placeholder; _this.placeholder = () => _this.t('placeholder', { 'default': _placeholder }); diff --git a/modules/ui/field.js b/modules/ui/field.js index 43aac7591..973f69728 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -140,7 +140,7 @@ export function uiField(context, presetField, entityIDs, options) { textEnter .append('span') .attr('class', 'label-textvalue') - .html(function(d) { return d.label(); }); + .each(function(d) { d.label()(d3_select(this)); }); textEnter .append('span') diff --git a/modules/ui/intro/area.js b/modules/ui/intro/area.js index 370f75a25..1ac4dec21 100644 --- a/modules/ui/intro/area.js +++ b/modules/ui/intro/area.js @@ -328,8 +328,8 @@ export function uiIntroArea(context, reveal) { timeout(function() { reveal('.more-fields .combobox-input', helpHtml('intro.areas.add_field', { - name: { html: nameField.label() }, - description: { html: descriptionField.label() } + name: nameField.title(), + description: descriptionField.title() }), { duration: 300 } ); @@ -395,7 +395,7 @@ export function uiIntroArea(context, reveal) { }, 300); reveal('div.combobox', - helpHtml('intro.areas.choose_field', { field: { html: descriptionField.label() } }), + helpHtml('intro.areas.choose_field', { field: descriptionField.title() }), { duration: 300 } ); @@ -456,7 +456,7 @@ export function uiIntroArea(context, reveal) { context.container().select('.inspector-wrap .panewrap').style('right', '0%'); reveal('.entity-editor-pane', - helpHtml('intro.areas.retry_add_field', { field: { html: descriptionField.label() } }), { + helpHtml('intro.areas.retry_add_field', { field: descriptionField.title() }), { buttonText: t.html('intro.ok'), buttonCallback: function() { continueTo(clickAddField); } }); diff --git a/modules/ui/intro/navigation.js b/modules/ui/intro/navigation.js index 8e5acad56..65c4c6710 100644 --- a/modules/ui/intro/navigation.js +++ b/modules/ui/intro/navigation.js @@ -493,8 +493,8 @@ export function uiIntroNavigation(context, reveal) { reveal('.entity-editor-pane', helpHtml('intro.navigation.street_different_fields') + '{br}' + helpHtml('intro.navigation.editor_street', { button: { html: icon(href, 'inline') }, - field1: { html: onewayField.label() }, - field2: { html: maxspeedField.label() } + field1: onewayField.title(), + field2: maxspeedField.title() })); context.on('exit.intro', function() { @@ -509,8 +509,8 @@ export function uiIntroNavigation(context, reveal) { reveal('.entity-editor-pane', helpHtml('intro.navigation.street_different_fields') + '{br}' + helpHtml('intro.navigation.editor_street', { button: { html: icon(href, 'inline') }, - field1: { html: onewayField.label() }, - field2: { html: maxspeedField.label() } + field1: onewayField.title(), + field2: maxspeedField.title() }), { duration: 0 } ); }); diff --git a/modules/ui/sections/preset_fields.js b/modules/ui/sections/preset_fields.js index ecb571eb5..6cafc4e6a 100644 --- a/modules/ui/sections/preset_fields.js +++ b/modules/ui/sections/preset_fields.js @@ -81,7 +81,7 @@ export function uiSectionPresetFields(context) { var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal()); additionalFields.sort(function(field1, field2) { - return field1.label().localeCompare(field2.label(), localizer.localeCode()); + return field1.title().localeCompare(field2.title(), localizer.localeCode()); }); additionalFields.forEach(function(field) {