From: Jo-Philipp Wich Date: Tue, 9 Feb 2016 15:10:55 +0000 (+0100) Subject: luci-base: fix dependency handling of optionals (#645) X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=cd85ef388cfb9134e3de490ff5d395f593783f8c luci-base: fix dependency handling of optionals (#645) Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 227461070..a8d323d6a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -490,6 +490,10 @@ function cbi_d_update() { state = true; } + + // hide optionals widget if no choices remaining + if (parent.parentNode && parent.getAttribute('data-optionals')) + parent.parentNode.style.display = (parent.options.length <= 1) ? 'none' : ''; } if (entry && entry.parent) { diff --git a/modules/luci-base/luasrc/view/cbi/ucisection.htm b/modules/luci-base/luasrc/view/cbi/ucisection.htm index 3b69f12f2..ba0cc53e8 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 -%> -
+
    <% for _, e in ipairs(self.error[section]) do -%>
  • <%- if e == "invalid" then -%> @@ -31,7 +31,7 @@ <%- end %> <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %> -
    +
    <% if self.dynamic then %> <% if self.optionals[section] and #self.optionals[section] > 0 then %> @@ -49,26 +49,12 @@ <% end %> <% else %> - <% for key, val in pairs(self.optionals[section]) do -%> - + <%- end %> - <% end %>