diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-03-29 22:33:35 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-03-29 22:35:50 +0200 |
commit | 2072c66c5a4b755a6ed16bb6486afb956a475be9 (patch) | |
tree | 0bf444f1e1384be32a80a525bbba55b4130a32c6 /modules/luci-mod-network/htdocs/luci-static | |
parent | ba4e214160619e27b88a3929c76a1a01c9c1b1e2 (diff) |
luci-mod-network: fix device section cleanup
Ensure that device sections are only automatically removed after all
related options have been parsed, to avoid prematurely deleting sections.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-network/htdocs/luci-static')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js b/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js index 3df72940aa..5ed55e24fc 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/tools/network.js @@ -145,24 +145,9 @@ function deviceWrite(section_id, formvalue) { } function deviceRemove(section_id) { - var ds = lookupDevSection(this.section, section_id, false), - sv = ds ? uci.get('network', ds) : null; - - if (sv) { - var empty = true; + var ds = lookupDevSection(this.section, section_id, false); - for (var opt in sv) { - if (opt.charAt(0) == '.' || opt == 'name' || opt == this.option) - continue; - - empty = false; - } - - if (empty) - uci.remove('network', ds); - else - uci.unset('network', ds, this.option); - } + uci.unset('network', ds, this.option); if (this.migrate) uci.unset('network', section_id, this.option); @@ -188,6 +173,28 @@ function deviceRefresh(section_id) { } } +function sectionParse() { + var ds = lookupDevSection(this, this.section, false); + + return form.NamedSection.prototype.parse.apply(this).then(function() { + var sv = ds ? uci.get('network', ds) : null; + + if (sv) { + var empty = true; + + for (var opt in sv) { + if (opt.charAt(0) == '.' || opt == 'name') + continue; + + empty = false; + } + + if (empty) + uci.remove('network', ds); + } + }); +} + var cbiTagValue = form.Value.extend({ renderWidget: function(section_id, option_index, cfgvalue) { @@ -387,6 +394,9 @@ return baseclass.extend({ o, ss; if (isIface) { + if (!s.hasOwnProperty('parse')) + s.parse = sectionParse; + var type; /* If an externally configured br-xxx interface already exists, |