From cb5cf7c08f3228109b8d7a247a0db1179aaac26f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 29 Mar 2021 22:29:36 +0200 Subject: [PATCH] luci-base: uci.js: merge changes when retrieving entire sections Signed-off-by: Jo-Philipp Wich (cherry picked from commit ba4e214160619e27b88a3929c76a1a01c9c1b1e2) --- .../htdocs/luci-static/resources/uci.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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; }, -- 2.30.2