From af928e3dc12c28e15ecf756c5a2394bc6e7143a6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 31 Jan 2020 13:02:30 -0500 Subject: [PATCH] Support radio fields during multiselections --- css/80_app.css | 3 +++ modules/ui/fields/radio.js | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/css/80_app.css b/css/80_app.css index f681207f2..8d2486096 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -1767,6 +1767,9 @@ a.hide-toggle { color: #7092ff; cursor: pointer; } +.form-field-input-radio > label.mixed { + font-style: italic; +} .form-field-input-radio > label:last-child { border-radius: 0 0 4px 4px; } diff --git a/modules/ui/fields/radio.js b/modules/ui/fields/radio.js index e3015c1c7..ee343dcfa 100644 --- a/modules/ui/fields/radio.js +++ b/modules/ui/fields/radio.js @@ -264,16 +264,29 @@ export function uiFieldRadio(field, context) { radio.tags = function(tags) { - function checked(d) { + + radios.property('checked', function(d) { if (field.key) { return tags[field.key] === d; - } else { - return !!(tags[d] && tags[d].toLowerCase() !== 'no'); } - } + return !!(typeof tags[d] === 'string' && tags[d].toLowerCase() !== 'no'); + }); + + labels + .classed('active', function(d) { + if (field.key) { + return (Array.isArray(tags[field.key]) && tags[field.key].includes(d)) + || tags[field.key] === d; + } + 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]); + }); - labels.classed('active', checked); - radios.property('checked', checked); var selection = radios.filter(function() { return this.checked; }); @@ -316,5 +329,3 @@ export function uiFieldRadio(field, context) { return utilRebind(radio, dispatch, 'on'); } - -uiFieldRadio.supportsMultiselection = false;