Backport Skip-Button support

This commit is contained in:
Steven Barth 2009-04-03 18:08:25 +00:00
parent baab33794b
commit f3deef9ec5
4 changed files with 21 additions and 5 deletions

View file

@ -42,6 +42,7 @@ FORM_PROCEED = 0
FORM_VALID = 1 FORM_VALID = 1
FORM_INVALID = -1 FORM_INVALID = -1
FORM_CHANGED = 2 FORM_CHANGED = 2
FORM_SKIP = 4
AUTO = true AUTO = true
@ -344,13 +345,19 @@ end
-- Use optimized UCI writing -- Use optimized UCI writing
function Map.parse(self, readinput, ...) function Map.parse(self, readinput, ...)
self.readinput = (readinput ~= false) self.readinput = (readinput ~= false)
if self:formvalue("cbi.skip") then
self.state = FORM_SKIP
return self:state_handler(self.state)
end
Node.parse(self, ...) Node.parse(self, ...)
if self.save then if self.save then
for i, config in ipairs(self.parsechain) do for i, config in ipairs(self.parsechain) do
self.uci:save(config) self.uci:save(config)
end 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 for i, config in ipairs(self.parsechain) do
self.uci:commit(config) self.uci:commit(config)
@ -561,6 +568,11 @@ SimpleForm.formvaluetable = Map.formvaluetable
function SimpleForm.parse(self, readinput, ...) function SimpleForm.parse(self, readinput, ...)
self.readinput = (readinput ~= false) self.readinput = (readinput ~= false)
if self:formvalue("cbi.skip") then
return FORM_SKIP
end
if self:submitstate() then if self:submitstate() then
Node.parse(self, 1, ...) Node.parse(self, 1, ...)
end end

View file

@ -14,6 +14,9 @@ $Id$
-%> -%>
<%- if pageaction then -%> <%- if pageaction then -%>
<div class="cbi-page-actions"> <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%> <% if not autoapply then%>
<input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:saveapply%>" /> <input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:saveapply%>" />
<% end %> <% end %>

View file

@ -33,6 +33,9 @@ $Id$
<%- end %> <%- end %>
<% if not self.embedded then %> <% if not self.embedded then %>
<div> <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 %> <%- if self.submit ~= false then %>
<input class="cbi-button-save" type="submit" value=" <input class="cbi-button-save" type="submit" value="
<%- if not self.submit then -%><%-:submit-%><%-else-%><%=self.submit%><%end-%> <%- if not self.submit then -%><%-:submit-%><%-else-%><%=self.submit%><%end-%>

View file

@ -640,9 +640,7 @@ local function _cbi(self, ...)
local state = nil local state = nil
for i, res in ipairs(maps) do for i, res in ipairs(maps) do
if config.autoapply then res.flow = config
res.autoapply = config.autoapply
end
local cstate = res:parse() local cstate = res:parse()
if cstate and (not state or cstate < state) then if cstate and (not state or cstate < state) then
state = cstate state = cstate
@ -682,7 +680,7 @@ local function _cbi(self, ...)
end end
end end
if not config.nofooter then 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
end end