From afdc349ab4ff6bc89b0527f36d5197b7896d86f4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 10 Feb 2016 19:33:01 +0100 Subject: [PATCH] luci-base: cbi: rework ListValue and MultiValue templates Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/view/cbi/lvalue.htm | 50 ++++++++++++++++++++------- modules/luci-base/luasrc/view/cbi/mvalue.htm | 51 ++++++++++++++++++++-------- 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/modules/luci-base/luasrc/view/cbi/lvalue.htm b/modules/luci-base/luasrc/view/cbi/lvalue.htm index ac63e9efd..61759fdd4 100644 --- a/modules/luci-base/luasrc/view/cbi/lvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/lvalue.htm @@ -1,18 +1,42 @@ +<% + local i, key + local br = self.orientation == "horizontal" and ' ' or '
' +%> + <%+cbi/valueheader%> <% if self.widget == "select" then %> - > + <% for i, key in pairs(self.keylist) do -%> + ><%=pcdata(self.vallist[i])%> + <%- end %> -<% elseif self.widget == "radio" then - local c = 0 - for i, key in pairs(self.keylist) do - c = c + 1 -%> - /> - ><%=self.vallist[i]%> -<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %> <% else %>
<% end %> -<% end end %> +<% elseif self.widget == "radio" then %> + > + <% for i, key in pairs(self.keylist) do %> + > + /> + <%=pcdata(self.vallist[i])%> + + <% if i == self.size then write(br) end %> + <% end %> + <% end %> <%+cbi/valuefooter%> diff --git a/modules/luci-base/luasrc/view/cbi/mvalue.htm b/modules/luci-base/luasrc/view/cbi/mvalue.htm index 79950cee2..ccdd6fcab 100644 --- a/modules/luci-base/luasrc/view/cbi/mvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/mvalue.htm @@ -1,19 +1,42 @@ -<% local v = self:valuelist(section) or {} -%> +<% + local i, key + local v = self:valuelist(section) or {} +-%> + <%+cbi/valueheader%> <% if self.widget == "select" then %> - > + <% for i, key in pairs(self.keylist) do -%> + ><%=pcdata(self.vallist[i])%> + <%- end %> -<% elseif self.widget == "checkbox" then - local c = 0; - for i, key in pairs(self.keylist) do - c = c + 1 -%> - /> - ><%=self.vallist[i]%>
-<% if c == self.size then c = 0 %>
-<% end end %> +<% elseif self.widget == "checkbox" then %> + > + <% for i, key in pairs(self.keylist) do %> + > + /> + <%=pcdata(self.vallist[i])%> + + <% if i == self.size then write('
') end %> + <% end %> + <% end %> <%+cbi/valuefooter%> -- 2.11.0