luci-base: ui.js: save filled out but not added dynlist items on submit
authorJo-Philipp Wich <jo@mein.io>
Tue, 30 Jul 2019 11:29:11 +0000 (13:29 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 30 Jul 2019 11:29:11 +0000 (13:29 +0200)
Fixes: #2938
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/ui.js

index 2ba0b0d1e874ae95712975c007666816853a4909..93e947d01d4feaf5109026cb07ec47e2e3cc44bc 100644 (file)
@@ -1327,11 +1327,16 @@ var UIDynamicList = UIElement.extend({
 
        getValue: function() {
                var items = this.node.querySelectorAll('.item > input[type="hidden"]'),
+                   input = this.node.querySelector('.add-item > input[type="text"]'),
                    v = [];
 
                for (var i = 0; i < items.length; i++)
                        v.push(items[i].value);
 
+               if (input && input.value != null && input.value.match(/\S/) &&
+                   v.filter(function(s) { return s == input.value }).length == 0)
+                       v.push(input.value);
+
                return v;
        },