CBI:
authorSteven Barth <steven@midlink.org>
Sun, 22 Nov 2009 20:32:56 +0000 (20:32 +0000)
committerSteven Barth <steven@midlink.org>
Sun, 22 Nov 2009 20:32:56 +0000 (20:32 +0000)
Implement reverse dependencies
Allow wiazrd steps without buttons

libs/cbi/htdocs/luci-static/resources/cbi.js
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/delegator.htm
libs/cbi/luasrc/view/cbi/header.htm

index 004e12eaa413ce23b1681c04071c14e76624f260..7ba81189eeb869a834b4ea71eb997f5550c06059 100644 (file)
@@ -59,15 +59,26 @@ function cbi_d_checkvalue(target, ref) {
 }
 
 function cbi_d_check(deps) {
+       var reverse;
+       var def = false;
        for (var i=0; i<deps.length; i++) {
-               var istat = true
+               var istat = true;
+               reverse = false;
                for (var j in deps[i]) {
-                       istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
+                       if (j.slice(-8) == "!reverse") {
+                               reverse = true;
+                       } else if (j.slice(-8) == "!default") {
+                               def = true;
+                               istat = false;
+                       } else {
+                               istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
+                       }
                }
                if (istat) {
-                       return true
+                       return !reverse;
                }
        }
+       return def;
 }
 
 function cbi_d_update() {
index 9b947cb2f0fe841dacab2316c334e6732db2c54c..e26558974633903cd1fb050313a3464796d8d511 100644 (file)
@@ -616,6 +616,7 @@ function Delegator.parse(self, ...)
                self.current = newcurrent or self.current
                self.active = self:get(self.current)
                if type(self.active) ~= "function" then
+                       self.active:populate_delegator(self)
                        self.active:parse(false)
                        return FROM_PROCEED
                else
index 08c1fe7c3a8311cef4dd9809fba7ae78a6b43209..a4a62af6405419ec4add7f530f6d35445aa05eef 100644 (file)
@@ -17,6 +17,7 @@ $Id$
 <% for _, x in ipairs(self.chain) do %>
                <input type="hidden" name="cbi.delg.path" value="<%=x%>" />
 <% end %>
+<% if not self.disallow_pageactions then %>
 <% if self.allow_back and self:get_prev(self.current) then %>
                <input class="cbi-button cbi-button-back" type="submit" name="cbi.delg.back" value="<%:« Back%>" />
 <% end %>
@@ -30,6 +31,7 @@ $Id$
        <input class="cbi-button cbi-button-finish" type="submit" value="<%:Finish%>" />
 <% elseif self:get_next(self.current) then %>
                <input class="cbi-button cbi-button-next" type="submit" value="<%:Next »%>" />
+<% end %>
 <% end %>
                <script type="text/javascript">cbi_d_update();</script>
-       </div>
+       </div>
\ No newline at end of file
index c831b0df1c4e37d0624e3ce6605fe6f2329bf294..bece16bb2a8fbeeb55f6b4508cacbe13f51a5680 100644 (file)
@@ -14,7 +14,7 @@ $Id$
 -%>
 
 <%+header%>
-<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
+<form method="post" name="cbi" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
        <div>
                <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
                <input type="hidden" name="cbi.submit" value="1" />