luci-base: uci.js: merge changes when retrieving entire sections

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ba4e214160)
This commit is contained in:
Jo-Philipp Wich 2021-03-29 22:29:36 +02:00
parent fc43d4d41c
commit cb5cf7c08f

View file

@ -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;
},