From cd85ef388cfb9134e3de490ff5d395f593783f8c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 9 Feb 2016 16:10:55 +0100 Subject: [PATCH] luci-base: fix dependency handling of optionals (#645) Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/resources/cbi.js | 4 ++++ .../luci-base/luasrc/view/cbi/ucisection.htm | 22 ++++--------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 2274610705..a8d323d6a8 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 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 -%> -
+
    <% 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 %>
    -- 2.30.2