summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-26 18:41:19 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-26 18:45:58 +0200
commit49c6a810e9a705217f4543099d8188f0f3158f6c (patch)
tree6c81ba24e8ee5948ba50ad55a255d512204f7787 /modules
parentbaa3bd4aac64984dfbecf8e524cfb31ed485a916 (diff)
luci-base: uci.js: fix section deletion logic
- Process deletions before additions or changes, allowing user code to remove and recreate a section with the same name. - Only record section deletions when the section to be removed actually existed in the original config or when it was staged for creation earlier. This avoids stray ubus not found exception when saving. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/uci.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/uci.js b/modules/luci-base/htdocs/luci-static/resources/uci.js
index e6582b3e2..640661f0f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/uci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/uci.js
@@ -301,7 +301,8 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
* The ID of the section to remove.
*/
remove: function(conf, sid) {
- var n = this.state.creates,
+ var v = this.state.values,
+ n = this.state.creates,
c = this.state.changes,
d = this.state.deletes;
@@ -309,7 +310,7 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
if (n[conf] && n[conf][sid]) {
delete n[conf][sid];
}
- else {
+ else if (v[conf] && v[conf][sid]) {
if (c[conf])
delete c[conf][sid];
@@ -791,6 +792,16 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
pkgs = { },
tasks = [];
+ if (d)
+ for (var conf in d) {
+ for (var sid in d[conf]) {
+ var o = d[conf][sid];
+ tasks.push(self.callDelete(conf, sid, (o === true) ? null : o));
+ }
+
+ pkgs[conf] = true;
+ }
+
if (n)
for (var conf in n) {
for (var sid in n[conf]) {
@@ -823,16 +834,6 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
pkgs[conf] = true;
}
- if (d)
- for (var conf in d) {
- for (var sid in d[conf]) {
- var o = d[conf][sid];
- tasks.push(self.callDelete(conf, sid, (o === true) ? null : o));
- }
-
- pkgs[conf] = true;
- }
-
if (r)
for (var conf in r)
pkgs[conf] = true;