summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/view
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2016-02-09 16:10:55 +0100
committerJo-Philipp Wich <jow@openwrt.org>2016-02-09 16:12:02 +0100
commitcd85ef388cfb9134e3de490ff5d395f593783f8c (patch)
tree1722d7ddd880dcfd3a461cdae09f1e2f1f3391dd /modules/luci-base/luasrc/view
parent84de513a79c1714ffa8e51009b7aa97ef975961d (diff)
luci-base: fix dependency handling of optionals (#645)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base/luasrc/view')
-rw-r--r--modules/luci-base/luasrc/view/cbi/ucisection.htm22
1 files changed, 4 insertions, 18 deletions
diff --git a/modules/luci-base/luasrc/view/cbi/ucisection.htm b/modules/luci-base/luasrc/view/cbi/ucisection.htm
index 3b69f12f2e..ba0cc53e87 100644
--- a/modules/luci-base/luasrc/view/cbi/ucisection.htm
+++ b/modules/luci-base/luasrc/view/cbi/ucisection.htm
@@ -15,7 +15,7 @@
<% end %>
<% if self.error and self.error[section] then -%>
- <div class="cbi-section-error">
+ <div class="cbi-section-error" data-index="<%=#self.children + 1%>">
<ul><% for _, e in ipairs(self.error[section]) do -%>
<li>
<%- if e == "invalid" then -%>
@@ -31,7 +31,7 @@
<%- end %>
<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
- <div class="cbi-optionals">
+ <div class="cbi-optionals" data-index="<%=#self.children + 1%>">
<% if self.dynamic then %>
<input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
<% if self.optionals[section] and #self.optionals[section] > 0 then %>
@@ -49,26 +49,12 @@
</script>
<% end %>
<% else %>
- <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
+ <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-optionals="true">
<option><%: -- Additional Field -- %></option>
<% for key, val in pairs(self.optionals[section]) do -%>
- <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
+ <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>" data-index="<%=val.index%>" data-depends="<%=pcdata(val:deplist2json(section))%>"><%=striptags(val.title)%></option>
<%- 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..d.add%>", {
- <%-
- for k,v in pairs(d.deps) do
- -%>
- <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
- <%-if next(d.deps, k) then-%>,<%-end-%>
- <%-
- end
- -%>
- });
- <%- end %><% end %>
- <% end %></script>
<% end %>
<input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
</div>