summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-04-03 18:08:25 +0000
committerSteven Barth <steven@midlink.org>2009-04-03 18:08:25 +0000
commitf3deef9ec570d49795346516d34c1b42fb416fde (patch)
treefe1a6cb694c4287b6dd4b671f6dca0ffa6cea81f /libs
parentbaab33794bb53375a7eddac72dace20b34db7862 (diff)
Backport Skip-Button support
Diffstat (limited to 'libs')
-rw-r--r--libs/cbi/luasrc/cbi.lua14
-rw-r--r--libs/cbi/luasrc/view/cbi/footer.htm3
-rw-r--r--libs/cbi/luasrc/view/cbi/simpleform.htm3
-rw-r--r--libs/web/luasrc/dispatcher.lua6
4 files changed, 21 insertions, 5 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index e7ad55047..ebca729bb 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -42,6 +42,7 @@ FORM_PROCEED = 0
FORM_VALID = 1
FORM_INVALID = -1
FORM_CHANGED = 2
+FORM_SKIP = 4
AUTO = true
@@ -344,13 +345,19 @@ end
-- Use optimized UCI writing
function Map.parse(self, readinput, ...)
self.readinput = (readinput ~= false)
+
+ if self:formvalue("cbi.skip") then
+ self.state = FORM_SKIP
+ return self:state_handler(self.state)
+ end
+
Node.parse(self, ...)
if self.save then
for i, config in ipairs(self.parsechain) do
self.uci:save(config)
end
- if self:submitstate() and not self.proceed and (self.autoapply or luci.http.formvalue("cbi.apply")) then
+ if self:submitstate() and not self.proceed and (self.flow.autoapply or luci.http.formvalue("cbi.apply")) then
for i, config in ipairs(self.parsechain) do
self.uci:commit(config)
@@ -561,6 +568,11 @@ SimpleForm.formvaluetable = Map.formvaluetable
function SimpleForm.parse(self, readinput, ...)
self.readinput = (readinput ~= false)
+
+ if self:formvalue("cbi.skip") then
+ return FORM_SKIP
+ end
+
if self:submitstate() then
Node.parse(self, 1, ...)
end
diff --git a/libs/cbi/luasrc/view/cbi/footer.htm b/libs/cbi/luasrc/view/cbi/footer.htm
index 4f94a05b0..b6e893d1a 100644
--- a/libs/cbi/luasrc/view/cbi/footer.htm
+++ b/libs/cbi/luasrc/view/cbi/footer.htm
@@ -14,6 +14,9 @@ $Id$
-%>
<%- if pageaction then -%>
<div class="cbi-page-actions">
+ <% if flow.skip then %>
+ <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:skip Skip%>" />
+ <% end %>
<% if not autoapply then%>
<input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:saveapply%>" />
<% end %>
diff --git a/libs/cbi/luasrc/view/cbi/simpleform.htm b/libs/cbi/luasrc/view/cbi/simpleform.htm
index e167a6e6d..9a23e53a8 100644
--- a/libs/cbi/luasrc/view/cbi/simpleform.htm
+++ b/libs/cbi/luasrc/view/cbi/simpleform.htm
@@ -33,6 +33,9 @@ $Id$
<%- end %>
<% if not self.embedded then %>
<div>
+<%- if self.flow.skip then %>
+ <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:skip Skip%>" />
+<% end %>
<%- if self.submit ~= false then %>
<input class="cbi-button-save" type="submit" value="
<%- if not self.submit then -%><%-:submit-%><%-else-%><%=self.submit%><%end-%>
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index 89fa0d22f..565e995d1 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -640,9 +640,7 @@ local function _cbi(self, ...)
local state = nil
for i, res in ipairs(maps) do
- if config.autoapply then
- res.autoapply = config.autoapply
- end
+ res.flow = config
local cstate = res:parse()
if cstate and (not state or cstate < state) then
state = cstate
@@ -682,7 +680,7 @@ local function _cbi(self, ...)
end
end
if not config.nofooter then
- tpl.render("cbi/footer", {pageaction=pageaction, state = state, autoapply = config.autoapply})
+ tpl.render("cbi/footer", {flow = config, pageaction=pageaction, state = state, autoapply = config.autoapply})
end
end