summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-10-14 23:21:25 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-10-14 23:21:25 +0000
commitfbaabd7d93e72506756e18988f98fca139e202e6 (patch)
treeccd8b12932330d429c3c2693047ed8e591738c6d /libs
parent4f8f03bc4f59f558430a7a4347de20464fe1668d (diff)
libs/web: cbi: add new on_before_save and on_after_save hook, implement :reset_values() for options supporting :value()
Diffstat (limited to 'libs')
-rw-r--r--libs/web/luasrc/cbi.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua
index 0a63d6090..5fa992dee 100644
--- a/libs/web/luasrc/cbi.lua
+++ b/libs/web/luasrc/cbi.lua
@@ -304,9 +304,11 @@ function Map.parse(self, readinput, ...)
Node.parse(self, ...)
if self.save then
+ self:_run_hooks("on_save", "on_before_save")
for i, config in ipairs(self.parsechain) do
self.uci:save(config)
end
+ self:_run_hooks("on_after_save")
if self:submitstate() and ((not self.proceed and self.flow.autoapply) or luci.http.formvalue("cbi.apply")) then
self:_run_hooks("on_before_commit")
for i, config in ipairs(self.parsechain) do
@@ -1402,6 +1404,11 @@ function Value.__init__(self, ...)
self.vallist = {}
end
+function Value.reset_values(self)
+ self.keylist = {}
+ self.vallist = {}
+end
+
function Value.value(self, key, val)
val = val or key
table.insert(self.keylist, tostring(key))
@@ -1487,6 +1494,11 @@ function ListValue.__init__(self, ...)
self.widget = "select"
end
+function ListValue.reset_values(self)
+ self.keylist = {}
+ self.vallist = {}
+end
+
function ListValue.value(self, key, val, ...)
if luci.util.contains(self.keylist, key) then
return
@@ -1537,6 +1549,11 @@ function MultiValue.render(self, ...)
AbstractValue.render(self, ...)
end
+function MultiValue.reset_values(self)
+ self.keylist = {}
+ self.vallist = {}
+end
+
function MultiValue.value(self, key, val)
if luci.util.contains(self.keylist, key) then
return
@@ -1613,6 +1630,11 @@ function DynamicList.__init__(self, ...)
self.vallist = {}
end
+function DynamicList.reset_values(self)
+ self.keylist = {}
+ self.vallist = {}
+end
+
function DynamicList.value(self, key, val)
val = val or key
table.insert(self.keylist, tostring(key))