Backport Skip-Button support
authorSteven Barth <steven@midlink.org>
Fri, 3 Apr 2009 18:08:25 +0000 (18:08 +0000)
committerSteven Barth <steven@midlink.org>
Fri, 3 Apr 2009 18:08:25 +0000 (18:08 +0000)
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/footer.htm
libs/cbi/luasrc/view/cbi/simpleform.htm
libs/web/luasrc/dispatcher.lua

index e7ad55047fb15155d65bdf8e4ec5ff8f52ab5da3..ebca729bbcd936859031da179f8ef74a78008246 100644 (file)
@@ -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
index 4f94a05b02c08ddfc244535f9c23ae94305a2bb9..b6e893d1ad1c8b6aace12d95bff9718d9c150fe6 100644 (file)
@@ -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 %>
index e167a6e6d9e47a749d56cdacf59aa82ef3ce9eff..9a23e53a83e38bc527a69c27a4d2f181080ef661 100644 (file)
@@ -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-%>
index 89fa0d22fc15cc4a924d6ac9615b64487cab93f5..565e995d191d5fdf38367db732dac746a471baa7 100644 (file)
@@ -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