diff --git a/modules/ui/field.js b/modules/ui/field.js index ee70f98c5..d2c34ebd8 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -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]; }); }; diff --git a/modules/ui/form_fields.js b/modules/ui/form_fields.js index bcb234558..25876376b 100644 --- a/modules/ui/form_fields.js +++ b/modules/ui/form_fields.js @@ -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();