From 9a7ac8d424f3324e8c7a831b52af43b3ddff5005 Mon Sep 17 00:00:00 2001 From: nikathone Date: Sat, 26 Sep 2020 01:42:23 -0400 Subject: [PATCH 1/2] Patch #39 by sedax --- js/models/WidgetModel.js | 5 + js/views/AppView.js | 16 +++- js/views/ContainerView.js | 12 ++- js/views/WidgetView.js | 79 ++++++++++++++-- shs.routing.yml | 8 ++ src/Controller/ShsController.php | 93 +++++++++++++++++++ .../Field/FieldWidget/OptionsShsWidget.php | 49 +++++++++- 7 files changed, 248 insertions(+), 14 deletions(-) diff --git a/js/models/WidgetModel.js b/js/models/WidgetModel.js index d62b4f4..2c299d9 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 8693214..dfed10a 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($("