in modules/ui/field.js [113:244]
field.render = function(selection) {
var container = selection.selectAll('.form-field')
.data([field]);
// Enter
var enter = container.enter()
.append('div')
.attr('class', function(d) { return 'form-field form-field-' + d.safeid; })
.classed('nowrap', !options.wrap);
if (options.wrap) {
var labelEnter = enter
.append('label')
.attr('class', 'field-label')
.attr('for', function(d) { return 'preset-input-' + d.safeid; });
var textEnter = labelEnter
.append('span')
.attr('class', 'label-text');
textEnter
.append('span')
.attr('class', 'label-textvalue')
.text(function(d) { return d.label(); });
textEnter
.append('span')
.attr('class', 'label-textannotation');
if (options.remove) {
labelEnter
.append('button')
.attr('class', 'remove-icon')
.attr('title', t('icons.remove'))
.attr('tabindex', -1)
.call(svgIcon('#iD-operation-delete'));
}
if (options.revert) {
labelEnter
.append('button')
.attr('class', 'modified-icon')
.attr('title', t('icons.undo'))
.attr('tabindex', -1)
.call(svgIcon((textDirection === 'rtl') ? '#iD-icon-redo' : '#iD-icon-undo'));
}
}
// Update
container = container
.merge(enter);
container.select('.field-label > .remove-icon') // propagate bound data
.on('click', remove);
container.select('.field-label > .modified-icon') // propagate bound data
.on('click', revert);
container
.each(function(d) {
var selection = d3_select(this);
if (!d.impl) {
createField();
}
var reference, help;
// instantiate field help
if (options.wrap && field.type === 'restrictions') {
help = uiFieldHelp(context, 'restrictions');
}
// instantiate tag reference
if (options.wrap && options.info) {
var referenceKey = d.key;
if (d.type === 'multiCombo') { // lookup key without the trailing ':'
referenceKey = referenceKey.replace(/:$/, '');
}
reference = uiTagReference(d.reference || { key: referenceKey }, context);
if (_state === 'hover') {
reference.showing(false);
}
}
selection
.call(d.impl);
// add field help components
if (help) {
selection
.call(help.body)
.select('.field-label')
.call(help.button);
}
// add tag reference components
if (reference) {
selection
.call(reference.body)
.select('.field-label')
.call(reference.button);
}
d.impl.tags(_tags);
});
container
.classed('locked', _locked)
.classed('modified', isModified())
.classed('present', isPresent());
// show a tip and lock icon if the field is locked
var annotation = container.selectAll('.field-label .label-textannotation');
var icon = annotation.selectAll('.icon')
.data(_locked ? [0]: []);
icon.exit()
.remove();
icon.enter()
.append('svg')
.attr('class', 'icon')
.append('use')
.attr('xlink:href', '#fas-lock');
container.call(_locked ? _lockedTip : _lockedTip.destroy);
};