diff options
author | Steven Barth <steven@midlink.org> | 2008-08-17 18:32:53 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-17 18:32:53 +0000 |
commit | 97ce1ad8adf935e2aa0d1b13f07b16d2d950053f (patch) | |
tree | d5eafec4b6996a6dc64046fd1d46a8f299cd4246 /libs/cbi/luasrc | |
parent | 1d08361bea91c11ba2f82f3ab3004c067ebabc85 (diff) |
Preparing rewrite of WiFi configuration
Diffstat (limited to 'libs/cbi/luasrc')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 16 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/cell_valuefooter.htm | 10 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/footer.htm | 2 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/full_valuefooter.htm | 10 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/lvalue.htm | 2 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/ucisection.htm | 13 |
6 files changed, 45 insertions, 8 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index fed53f6ee8..6cc0908823 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -710,7 +710,15 @@ end -- Add a dependencie to another section field function AbstractValue.depends(self, field, value) - table.insert(self.deps, {field=field, value=value}) + local deps + if type(field) == "string" then + deps = {} + deps[field] = value + else + deps = field + end + + table.insert(self.deps, {deps=deps, add=""}) end -- Generates the unique CBID @@ -897,10 +905,14 @@ function ListValue.__init__(self, ...) self.widget = "select" end -function ListValue.value(self, key, val) +function ListValue.value(self, key, val, ...) val = val or key table.insert(self.keylist, tostring(key)) table.insert(self.vallist, tostring(val)) + + for i, deps in ipairs({...}) do + table.insert(self.deps, {add = "-"..key, deps=deps}) + end end function ListValue.validate(self, val) diff --git a/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm b/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm index 9412142465..7d1ac4ee68 100644 --- a/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm +++ b/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm @@ -25,7 +25,15 @@ $Id$ <% if #self.deps > 0 then -%> <script type="text/javascript"> <% for j, d in ipairs(self.deps) do -%> - cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>"); + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + -%> + <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>, + <%- + end + -%> + }); <%- end %> </script> <%- end %> diff --git a/libs/cbi/luasrc/view/cbi/footer.htm b/libs/cbi/luasrc/view/cbi/footer.htm index b719058200..a688fcddde 100644 --- a/libs/cbi/luasrc/view/cbi/footer.htm +++ b/libs/cbi/luasrc/view/cbi/footer.htm @@ -17,7 +17,7 @@ $Id$ <input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:saveapply%>" /> <input class="cbi-button cbi-button-save" type="submit" value="<%:save%>" /> <input class="cbi-button cbi-button-reset" type="reset" value="<%:reset%>" /> - <script type="text/javascript">cbi_d_init();</script> + <script type="text/javascript">cbi_d_update();</script> </div> </form> <%+footer%> diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm index 5a52898d17..8084cfda98 100644 --- a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm +++ b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm @@ -34,7 +34,15 @@ $Id$ <% if #self.deps > 0 then -%> <script type="text/javascript"> <% for j, d in ipairs(self.deps) do -%> - cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>"); + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + -%> + <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>, + <%- + end + -%> + }); <%- end %> </script> <%- end %> diff --git a/libs/cbi/luasrc/view/cbi/lvalue.htm b/libs/cbi/luasrc/view/cbi/lvalue.htm index 5108e85c48..60dd682808 100644 --- a/libs/cbi/luasrc/view/cbi/lvalue.htm +++ b/libs/cbi/luasrc/view/cbi/lvalue.htm @@ -16,7 +16,7 @@ $Id$ <% if self.widget == "select" then %> <select onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>> <% for i, key in pairs(self.keylist) do -%> - <option<%= attr("value", key) .. ifattr(self:cfgvalue(section) == key, "selected", "selected") %>><%=luci.util.pcdata(self.vallist[i])%></option> + <option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr(self:cfgvalue(section) == key, "selected", "selected") %>><%=luci.util.pcdata(self.vallist[i])%></option> <%- end %> </select> <% elseif self.widget == "radio" then diff --git a/libs/cbi/luasrc/view/cbi/ucisection.htm b/libs/cbi/luasrc/view/cbi/ucisection.htm index 2ae8560038..f8cf3d1bc0 100644 --- a/libs/cbi/luasrc/view/cbi/ucisection.htm +++ b/libs/cbi/luasrc/view/cbi/ucisection.htm @@ -27,8 +27,17 @@ $Id$ <%- end %> </select> <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %> - <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>"); - <% end %><% end %> + <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%> + cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", { + <%- + for k,v in pairs(d.deps) do + -%> + <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>, + <%- + end + -%> + }); + <%- end %><% end %> <% end %></script> <% end %> <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" /> |