From a876aa010cb0477f74e351fdf0d5aab04a8bd8cb Mon Sep 17 00:00:00 2001 From: Kyle Hensel Date: Sat, 25 Nov 2023 21:48:54 +1300 Subject: [PATCH 1/4] show empty tag values in multi-selections --- data/core.yaml | 1 + modules/ui/combobox.js | 2 +- modules/ui/sections/raw_tag_editor.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 4eb68fd64..864efd53d 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -725,6 +725,7 @@ en: wiki_reference: View documentation wiki_en_reference: View documentation in English key_value: "key=value" + empty: (empty) multiple_values: Multiple Values multiple_types: Multiple Types unshared_value_tooltip: not shared by all features diff --git a/modules/ui/combobox.js b/modules/ui/combobox.js index 3914fd186..8cbc03401 100644 --- a/modules/ui/combobox.js +++ b/modules/ui/combobox.js @@ -403,7 +403,7 @@ export function uiCombobox(context, klass) { if (d.display) { d.display(d3_select(this)); } else { - d3_select(this).text(d.value); + d3_select(this).text(d.title); } }) .on('mouseenter', _mouseEnterHandler) diff --git a/modules/ui/sections/raw_tag_editor.js b/modules/ui/sections/raw_tag_editor.js index d089ec41c..879d21771 100644 --- a/modules/ui/sections/raw_tag_editor.js +++ b/modules/ui/sections/raw_tag_editor.js @@ -411,7 +411,13 @@ export function uiSectionRawTagEditor(id, context) { .fetcher(function(value, callback) { var keyString = utilGetSetValue(key); if (!_tags[keyString]) return; - var data = _tags[keyString].filter(Boolean).map(function(tagValue) { + var data = _tags[keyString].map(function(tagValue) { + if (!tagValue) { + return { + value: ' ', + title: t('inspector.empty'), + }; + } return { value: tagValue, title: tagValue @@ -549,6 +555,9 @@ export function uiSectionRawTagEditor(id, context) { // exit if this is a multiselection and no value was entered if (typeof d.value !== 'string' && !this.value) return; + // remove tag if it is now empty + if (!this.value.trim()) return removeTag(d3_event, d); + // exit if we are currently about to delete this row anyway - #6366 if (_pendingChange && _pendingChange.hasOwnProperty(d.key) && _pendingChange[d.key] === undefined) return; From 0d69c3c9e8a761837b4364cba4b28e1bb8b718de Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Wed, 6 Dec 2023 13:56:45 +0100 Subject: [PATCH 2/4] style "(empty)" option differently to distinguish from regular tag values --- css/80_app.css | 5 +++++ modules/ui/sections/raw_tag_editor.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/css/80_app.css b/css/80_app.css index b97964d64..16eb06aca 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -2406,6 +2406,11 @@ div.combobox { color: #333; } +.combobox .combobox-option.virtual-option { + font-style: italic; + color: #333; +} + .form-field-input-wrap { position: relative; } diff --git a/modules/ui/sections/raw_tag_editor.js b/modules/ui/sections/raw_tag_editor.js index 879d21771..44d7fadd9 100644 --- a/modules/ui/sections/raw_tag_editor.js +++ b/modules/ui/sections/raw_tag_editor.js @@ -416,6 +416,9 @@ export function uiSectionRawTagEditor(id, context) { return { value: ' ', title: t('inspector.empty'), + display: selection => selection.text('') + .classed('virtual-option', true) + .call(t.append('inspector.empty')) }; } return { From f65ca4c3423150cc8b377a65aea78a8dac1e9709 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Wed, 6 Dec 2023 14:03:47 +0100 Subject: [PATCH 3/4] use tag value as display text in raw tag editor --- modules/ui/combobox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/combobox.js b/modules/ui/combobox.js index 8cbc03401..3914fd186 100644 --- a/modules/ui/combobox.js +++ b/modules/ui/combobox.js @@ -403,7 +403,7 @@ export function uiCombobox(context, klass) { if (d.display) { d.display(d3_select(this)); } else { - d3_select(this).text(d.title); + d3_select(this).text(d.value); } }) .on('mouseenter', _mouseEnterHandler) From ae894f00900a9ad33c466e0ddf7c53c40b07d03c Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Wed, 6 Dec 2023 14:13:06 +0100 Subject: [PATCH 4/4] add to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5805b44ec..90b4dd957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :sparkles: Usability & Accessibility * Show the color of (route) relations in the form of small colored circles in relation membership section and feature search results ([#9424]) * Hide tag suggestions for tags like `name_1` in raw tag editor autocomplete ([#9422]) +* Show `(empty)` as a tag value option in the raw tag editor when a multi selections contains at least one feature which does not have the particular tag ([#9876], thanks [@k-yle]) #### :scissors: Operations #### :camera: Street-Level #### :white_check_mark: Validation @@ -53,6 +54,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9424]: https://github.com/openstreetmap/iD/pull/9424 [#9422]: https://github.com/openstreetmap/iD/issues/9422 +[#9876]: https://github.com/openstreetmap/iD/issues/9876 [#9983]: https://github.com/openstreetmap/iD/issues/9983