diff --git a/css/shs.form.css b/css/shs.form.css index 3ec9ed1fb..39f4d0b74 100644 --- a/css/shs.form.css +++ b/css/shs.form.css @@ -16,3 +16,7 @@ .shs-addnew-container { margin-top: .5rem; } + +.shs-field-container .shs-select:empty { + display: none !important; +} \ No newline at end of file diff --git a/js/models/WidgetModel.js b/js/models/WidgetModel.js index d5c3895cb..32847c978 100644 --- a/js/models/WidgetModel.js +++ b/js/models/WidgetModel.js @@ -31,6 +31,11 @@ */ defaultValue: '_none', + /** + * The new item that was created. + */ + createValue: null, + /** * Position of widget in app. * diff --git a/js/views/AppView.js b/js/views/AppView.js index 8693214dd..dfed10a5b 100644 --- a/js/views/AppView.js +++ b/js/views/AppView.js @@ -65,9 +65,6 @@ parents: parents })); }); -// $.each(app.getConfig('parents'), function (index, item) { -// // Add WidgetModel for each parent. -// }); app.collection.trigger('initialize:shs'); @@ -127,6 +124,19 @@ // Use value of parent widget (which is the id of the model ;)). value = widgetModel.get('id'); } + else if (widgetModel.get('createValue')) { + // Add the created item to the original select item. + var options = $("option", app.$el).map(function () { + return $(this).val(); + }).get(); + if ($.inArray(value, options) === -1) { + var item = widgetModel.get('createValue'); + app.$el.append($("