luci-base: don't treat .rmempty flag as optional for ListValue widgets
authorJo-Philipp Wich <jo@mein.io>
Sat, 27 Jul 2019 20:17:33 +0000 (22:17 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sat, 27 Jul 2019 20:33:36 +0000 (22:33 +0200)
Restore the old CBI behaviour of not automatically rendering empty
selection choices in ListValue select dropdowns when .rmempty is
specified.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js
modules/luci-base/htdocs/luci-static/resources/ui.js
modules/luci-base/luasrc/view/cbi/lvalue.htm

index 58d8f7100c92a2c6ddc0bc7379d1b51870a74f76..ef2f18e35a56d72c4a3f3962be91fe9229cc09ba 100644 (file)
@@ -1460,7 +1460,7 @@ var CBIListValue = CBIValue.extend({
                        id: this.cbid(section_id),
                        size: this.size,
                        sort: this.keylist,
-                       optional: this.rmempty || this.optional,
+                       optional: this.optional,
                        placeholder: this.placeholder,
                        validate: L.bind(this.validate, this, section_id)
                });
index 43afc698f64b977064fade858f48158a671577ab..2ba0b0d1e874ae95712975c007666816853a4909 100644 (file)
@@ -243,7 +243,7 @@ var UISelect = UIElement.extend({
                                'multiple': this.options.multiple ? '' : null
                        }));
 
-                       if (this.options.optional)
+                       if (this.options.optional || this.choices.hasOwnProperty(''))
                                frameEl.lastChild.appendChild(E('option', {
                                        'value': '',
                                        'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null
index 920b5e9f92210bacaa95f2305b79cdd719cab143..28141472f45593fc2ec3dc31e16e34b630326bea 100644 (file)
@@ -7,7 +7,7 @@
                sort = self.keylist,
                widget = self.widget,
                datatype = self.datatype,
-               optional = self.optional or self.rmempty,
+               optional = self.optional,
                placeholder = self.placeholder
        }
 }))%>></div>