diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-10-06 15:37:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 15:37:03 +0200 |
commit | 8959bfff972f0ca26d9941463a26760850cdbdfb (patch) | |
tree | 76b198fa1337843e99be496d37bad07f5b6198c8 /modules | |
parent | 6483e802671e008a288fcf8f4b8951e92ec6d774 (diff) | |
parent | a75ae38b6b36fec76c259c8313857003f5b23841 (diff) |
Merge pull request #4496 from TDT-AG/pr/20201006-luci-mod-system-leds
luci-mod-system: fix uci led option remove callback
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js | 26 |
1 files changed, 26 insertions, 0 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 9fe1bff55..23feebc00 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 @@ -88,6 +88,32 @@ return view.extend({ var plugin = plugins[i]; plugin.form.addFormOptions(s); } + + var opts = s.getOption(); + + var removeIfNoneActive = function(original_remove_fn, section_id) { + var isAnyActive = false; + + for (var optname in opts) { + if (opts[optname].ucioption != this.ucioption) + continue; + + if (!opts[optname].isActive(section_id)) + continue; + + isAnyActive = true; + break; + } + + if (!isAnyActive) + original_remove_fn.call(this, section_id); + }; + + for (var optname in opts) { + if (!opts[optname].ucioption || optname == opts[optname].ucioption) + continue; + opts[optname].remove = removeIfNoneActive.bind(opts[optname], opts[optname].remove); + } }; return m.render(); |