summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-30 19:01:07 +0000
committerSteven Barth <steven@midlink.org>2008-07-30 19:01:07 +0000
commit5c7ab6430647c7f505caa89180f8e4907329862d (patch)
treef6588b00c957bcbd440024713d6e246219d72da2 /libs/cbi
parent8c3ee6f9b7e5ab0b4edbf4838c7c1a9ee6d7df5d (diff)
libs/cbi: Fixed CBI handling of "Save & Apply"
Diffstat (limited to 'libs/cbi')
-rw-r--r--libs/cbi/luasrc/cbi.lua30
1 files changed, 27 insertions, 3 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index e6952899f6..fe99f0246b 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -144,20 +144,44 @@ function Map.__init__(self, config, ...)
Node._i18n(self, config, nil, nil, ...)
self.config = config
+ self.parsechain = {self.config}
self.template = "cbi/map"
if not uci.load(self.config) then
error("Unable to read UCI data: " .. self.config)
end
end
+
+-- Chain foreign config
+function Map.chain(self, config)
+ table.insert(self.parsechain, config)
+end
+
-- Use optimized UCI writing
function Map.parse(self, ...)
Node.parse(self, ...)
- uci.save(self.config)
+ for i, config in ipairs(self.parsechain) do
+ uci.save(config)
+ end
if luci.http.formvalue("cbi.apply") then
- uci.commit(self.config)
+ for i, config in ipairs(self.parsechain) do
+ uci.commit(config)
+ if luci.config.uci_oncommit and luci.config.uci_oncommit[config] then
+ luci.sys.exec(luci.config.uci_oncommit[config])
+ end
+
+ -- Refresh data because commit changes section names
+ uci.unload(config)
+ uci.load(config)
+ end
+
+ -- Reparse sections
+ Node.parse(self, ...)
+
+ end
+ for i, config in ipairs(self.parsechain) do
+ uci.unload(config)
end
- uci.unload(self.config)
end
-- Creates a child section