libs/cbi: implement tabbing to split large sections and group options in tabs
[project/luci.git] / libs / cbi / luasrc / view / cbi / ucisection.htm
index e571cb2..a8b313d 100644 (file)
@@ -13,14 +13,26 @@ $Id$
 
 -%>
 
-<% self:render_children(section, scope or {}) %>
+<%-
+       if type(self.hidden) == "table" then
+               for k, v in pairs(self.hidden) do
+-%>
+       <input type="hidden" id="cbid.<%=self.config%>.<%=section%>.<%=k%>" name="cbid.<%=self.config%>.<%=section%>.<%=k%>" value="<%=pcdata(v)%>" />
+<%-
+               end
+       end
+%>
+
+<% if self.tabs then %>
+       <%+cbi/tabcontainer%>
+<% else %>
+       <% self:render_children(section, scope or {}) %>
+<% end %>
 
-<% if self.tag_deperror[section] then -%>
-       <div class="cbi-error"><%:cbi_deperror%></div>
-<% elseif self.tag_invalid[section] then -%>
-       <div class="cbi-error"><%:cbi_invalid_section%></div>
-<%- elseif self.tag_error[section] then -%>
-       <div class="cbi-error"><%=self.tag_error[section]%></div>
+<% if self.error and self.error[section] then -%>
+       <div class="cbi-section-error">
+               <ul><% for _, e in ipairs(self.error[section]) do %><li><%=pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
+       </div>
 <%- end %>
 
 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
@@ -33,7 +45,8 @@ $Id$
                                <%-
                                        for i, val in pairs(self.optionals[section]) do
                                -%>
-                                       <%-=string.format("%q", striptags(val.title)) .. ":" .. string.format("%q", val.option)-%>,
+                                       <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
+                                       <%-if next(self.optionals[section], i) then-%>,<%-end-%>
                                <%-
                                        end
                                -%>
@@ -41,7 +54,7 @@ $Id$
                        </script>
                        <% end %>
                <% else %>
-               <select name="cbi.opt.<%=self.config%>.<%=section%>">
+               <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
                        <option><%:cbi_addopt%></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>
@@ -53,7 +66,8 @@ $Id$
                <%-
                        for k,v in pairs(d.deps) do
                -%>
-                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>,
+                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
                <%-
                        end
                -%>