From: Jo-Philipp Wich Date: Mon, 29 Mar 2021 20:29:36 +0000 (+0200) Subject: luci-base: uci.js: merge changes when retrieving entire sections X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=ba4e214160619e27b88a3929c76a1a01c9c1b1e2;p=openwrt-luci.git luci-base: uci.js: merge changes when retrieving entire sections Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/uci.js b/modules/luci-base/htdocs/luci-static/resources/uci.js index cbaeb8c080..41e902c5fe 100644 --- a/modules/luci-base/htdocs/luci-static/resources/uci.js +++ b/modules/luci-base/htdocs/luci-static/resources/uci.js @@ -489,8 +489,28 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ { } /* requested an entire section */ - if (v[conf]) - return v[conf][sid]; + if (v[conf]) { + /* check whether entire section was deleted */ + if (d[conf] && d[conf][sid] === true) + return null; + + var s = v[conf][sid] || null; + + if (s) { + /* merge changes */ + if (c[conf] && c[conf][sid]) + for (var opt in c[conf][sid]) + if (c[conf][sid][opt] != null) + s[opt] = c[conf][sid][opt]; + + /* merge deletions */ + if (d[conf] && d[conf][sid]) + for (var opt in d[conf][sid]) + delete s[opt]; + } + + return s; + } return null; },