summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-system/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-18 18:53:21 +0200
committerJo-Philipp Wich <jo@mein.io>2019-10-18 18:55:10 +0200
commit45b56e85a62c23b12f43dc8bcf60bb3930cbbe9f (patch)
treeb7bbaae3aa063cb47543211c83335805b8f5cf09 /modules/luci-mod-system/htdocs/luci-static/resources
parent254503dc8a4ae7c7791ad96da835d72555796e4d (diff)
luci-mod-system: leds.js: fix handling device option
Since the modal overlay map was unable to read the current trigger value, it mistakingly allowed the removal of the device option value. Fix it by finding the option object through lookupOption() instead of relying on a reference. Fixes: #3216 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/htdocs/luci-static/resources')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js
index 8a93aeb8c..139db8797 100644
--- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js
@@ -30,7 +30,7 @@ return L.view.extend({
var leds = results[0],
usb = results[1],
triggers = {},
- trigger, m, s, o;
+ m, s, o;
for (var k in leds)
for (var i = 0; i < leds[k].triggers.length; i++)
@@ -54,12 +54,12 @@ return L.view.extend({
o = s.option(form.Flag, 'default', _('Default state'));
o.rmempty = false;
- trigger = s.option(form.ListValue, 'trigger', _('Trigger'));
+ o = s.option(form.ListValue, 'trigger', _('Trigger'));
if (usb.devices && usb.devices.length)
triggers['usbdev'] = true;
if (usb.ports && usb.ports.length)
triggers['usbport'] = true;
- Object.keys(triggers).sort().forEach(function(t) { trigger.value(t, t.replace(/-/g, '')) });
+ Object.keys(triggers).sort().forEach(function(t) { o.value(t, t.replace(/-/g, '')) });
o = s.option(form.Value, 'delayon', _('On-State Delay'));
o.modalonly = true;
@@ -76,8 +76,10 @@ return L.view.extend({
o.noaliases = true;
o.depends('trigger', 'netdev');
o.remove = function(section_id) {
- var t = trigger.formvalue(section_id);
- if (t != 'netdev' && t != 'usbdev')
+ var topt = this.map.lookupOption('trigger', section_id),
+ tval = topt ? topt[0].formvalue(section_id) : null;
+
+ if (tval != 'netdev' && tval != 'usbdev')
uci.unset('system', section_id, 'dev');
};
@@ -96,8 +98,10 @@ return L.view.extend({
o.ucioption = 'dev';
o.modalonly = true;
o.remove = function(section_id) {
- var t = trigger.formvalue(section_id);
- if (t != 'netdev' && t != 'usbdev')
+ var topt = this.map.lookupOption('trigger', section_id),
+ tval = topt ? topt[0].formvalue(section_id) : null;
+
+ if (tval != 'netdev' && tval != 'usbdev')
uci.unset('system', section_id, 'dev');
}
o.value('');