From 2783408fc3810fb58dae2c1f52790330c96bad20 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 31 Jan 2020 14:07:16 -0500 Subject: [PATCH] Add tooltips to mixed values in semicombo, multicombo, and radio fields --- data/core.yaml | 1 + dist/locales/en.json | 1 + modules/ui/fields/combo.js | 3 +++ modules/ui/fields/radio.js | 15 ++++++++++----- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 034491c4e..d68008f9a 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -555,6 +555,7 @@ en: key_value: "key=value" multiple_values: Multiple Values multiple_types: Multiple Types + unshared_value_tooltip: not shared by all features hidden_preset: manual: "{features} are hidden. Enable them in the Map Data pane." zoom: "{features} are hidden. Zoom in to enable them." diff --git a/dist/locales/en.json b/dist/locales/en.json index 0509bce1c..04338db60 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -694,6 +694,7 @@ "key_value": "key=value", "multiple_values": "Multiple Values", "multiple_types": "Multiple Types", + "unshared_value_tooltip": "not shared by all features", "hidden_preset": { "manual": "{features} are hidden. Enable them in the Map Data pane.", "zoom": "{features} are hidden. Zoom in to enable them." diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index 1782c3c99..b5fe3c793 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -526,6 +526,9 @@ export function uiFieldCombo(field, context) { .classed('draggable', allowDragAndDrop) .classed('mixed', function(d) { return d.isMixed; + }) + .attr('title', function(d) { + return d.isMixed ? t('inspector.unshared_value_tooltip') : null; }); if (allowDragAndDrop) { diff --git a/modules/ui/fields/radio.js b/modules/ui/fields/radio.js index ee343dcfa..53371c3c8 100644 --- a/modules/ui/fields/radio.js +++ b/modules/ui/fields/radio.js @@ -272,6 +272,13 @@ export function uiFieldRadio(field, context) { return !!(typeof tags[d] === 'string' && tags[d].toLowerCase() !== 'no'); }); + function isMixed(d) { + if (field.key) { + return Array.isArray(tags[field.key]) && tags[field.key].includes(d); + } + return Array.isArray(tags[d]); + } + labels .classed('active', function(d) { if (field.key) { @@ -280,11 +287,9 @@ export function uiFieldRadio(field, context) { } return Array.isArray(tags[d]) || !!(tags[d] && tags[d].toLowerCase() !== 'no'); }) - .classed('mixed', function(d) { - if (field.key) { - return Array.isArray(tags[field.key]) && tags[field.key].includes(d); - } - return Array.isArray(tags[d]); + .classed('mixed', isMixed) + .attr('title', function(d) { + return isMixed(d) ? t('inspector.unshared_value_tooltip') : null; });