Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions modules/ui/fields/radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { presetManager } from '../../presets';
import { t } from '../../core/localizer';
import { uiField } from '../field';
import { utilArrayUnion, utilRebind } from '../../util';
import { formatTag } from './tag_title';


export { uiFieldRadio as uiFieldStructureRadio };
Expand Down Expand Up @@ -271,6 +272,9 @@ export function uiFieldRadio(field, context) {

radio.tags = function(tags) {
_tags = tags;

wrap.selectAll('label.unknown-radio-option').remove();

function isOptionChecked(d) {
if (field.key) {
return tags[field.key] === d;
Expand Down Expand Up @@ -301,15 +305,38 @@ export function uiFieldRadio(field, context) {
})
.classed('mixed', isMixed)
.attr('title', function(d) {
return isMixed(d) ? t('inspector.unshared_value_tooltip') : null;
if (isMixed(d)) return t('inspector.unshared_value_tooltip');
if (!field.key) return null;
const desc = strings.hasTextForStringId('options.' + d + '.description')
? strings.t('options.' + d + '.description') : undefined;
const tag = formatTag(field.key, d);
return desc ? `${desc}\n${tag}` : tag;
});


var selection = radios.filter(function() { return this.checked; });

if (selection.empty()) {
placeholder.text('');
placeholder.call(t.append('inspector.none'));
var unknownVal = field.key && tags[field.key] && !Array.isArray(tags[field.key])
? tags[field.key]
: null;

if (unknownVal) {
var unknownLabel = wrap.append('label')
.attr('class', 'unknown-radio-option');

unknownLabel.append('input')
.attr('type', 'radio')
.attr('name', field.id)
.property('checked', true);

unknownLabel.append('span')
.text('"' + unknownVal + '"');

} else {
placeholder.text('');
placeholder.call(t.append('inspector.none'));
}
} else {
placeholder.text(selection.attr('value'));
_oldType[selection.datum()] = tags[selection.datum()];
Expand Down