mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-26 07:23:40 +00:00
When showing a field, set its default value if it has one
This allows universal fields or other standalone fields to have a default value. This didn't work before becuase default values were only handled by preset.applyTags() / preset.removeTags().
This commit is contained in:
@@ -18,6 +18,7 @@ export function uiField(context, presetField, entity, options) {
|
||||
|
||||
var dispatch = d3.dispatch('change'),
|
||||
field = _.clone(presetField),
|
||||
show = options.show,
|
||||
state = '',
|
||||
tags = {};
|
||||
|
||||
@@ -33,8 +34,6 @@ export function uiField(context, presetField, entity, options) {
|
||||
|
||||
field.keys = field.keys || [field.key];
|
||||
|
||||
field.show = options.show;
|
||||
|
||||
|
||||
function isModified() {
|
||||
if (!entity) return false;
|
||||
@@ -176,8 +175,18 @@ export function uiField(context, presetField, entity, options) {
|
||||
};
|
||||
|
||||
|
||||
field.show = function() {
|
||||
show = true;
|
||||
if (field.default && field.key && tags[field.key] !== field.default) {
|
||||
var t = {};
|
||||
t[field.key] = field.default;
|
||||
dispatch.call('change', this, t);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
field.isShown = function() {
|
||||
return field.show || _.some(field.keys, function(key) { return !!tags[key]; });
|
||||
return show || _.some(field.keys, function(key) { return !!tags[key]; });
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ export function uiFormFields(context) {
|
||||
.minItems(1)
|
||||
.on('accept', function (d) {
|
||||
var field = d.field;
|
||||
field.show = true;
|
||||
field.show();
|
||||
render(selection);
|
||||
if (field.type !== 'semiCombo' && field.type !== 'multiCombo') {
|
||||
field.focus();
|
||||
|
||||
Reference in New Issue
Block a user