luci-base: widgets.js: CBIZoneSelect: fix availability of "device" choice
authorJo-Philipp Wich <[email protected]>
Mon, 22 Jul 2019 06:40:38 +0000 (08:40 +0200)
committerJo-Philipp Wich <[email protected]>
Mon, 22 Jul 2019 06:40:38 +0000 (08:40 +0200)
Ref: https://github.com/openwrt/luci/issues/2889
Signed-off-by: Jo-Philipp Wich <[email protected]>
modules/luci-base/htdocs/luci-static/resources/tools/widgets.js

index 90e2512a685151855b25f3d2537fc4288566a75e..e79cb2aeffa4a1e5ee1e77b0a620622d47e7e2f2 100644 (file)
@@ -150,11 +150,14 @@ var CBIZoneSelect = form.ListValue.extend({
                                }
                                else {
                                        var anyval = node.querySelector('[data-value="*"]'),
-                                           emptyval = node.querySelector('[data-value=""]') || anyval.cloneNode(true);
+                                           emptyval = node.querySelector('[data-value=""]');
 
-                                       emptyval.removeAttribute('display');
-                                       emptyval.removeAttribute('selected');
-                                       emptyval.setAttribute('data-value', '');
+                                       if (emptyval == null) {
+                                               emptyval = anyval.cloneNode(true);
+                                               emptyval.removeAttribute('display');
+                                               emptyval.removeAttribute('selected');
+                                               emptyval.setAttribute('data-value', '');
+                                       }
 
                                        L.dom.content(emptyval.querySelector('span'), [
                                                E('strong', _('Device')), ' (%s)'.format(_('input'))
@@ -171,8 +174,9 @@ var CBIZoneSelect = form.ListValue.extend({
                }
                else if (this.option == 'dest') {
                        for (var i = 0; i < this.section.children.length; i++) {
-                               if (this.section.children[i].option == 'src') {
-                                       if (!this.section.children[i].cfgvalue(section_id)) {
+                               var opt = this.section.children[i];
+                               if (opt.option == 'src') {
+                                       if (!opt.cfgvalue(section_id) && !opt.default) {
                                                var emptyval = elem.querySelector('[data-value=""]');
 
                                                if (emptyval != null)