<%- local rowcnt = 0 function rowstyle() rowcnt = rowcnt + 1 if rowcnt % 2 == 0 then return " cbi-rowstyle-1" else return " cbi-rowstyle-2" end end function width(o) if o.width then if type(o.width) == "number" then return ' style="width:%dpx"' % o.width end return ' style="width:%s"' % o.width end return "" end local has_titles = false local has_descriptions = false local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous" local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name")) local i, k for i, k in pairs(self.children) do if not k.typename then k.typename = k.template and k.template:gsub("^.+/", "") or "" end if not has_titles and k.title and #k.title > 0 then has_titles = true end if not has_descriptions and k.description and #k.description > 0 then has_descriptions = true end end local total = tonumber(self.server_total) or 0 local page = tonumber(self.server_page) or 1 local page_size = tonumber(self.server_page_size) or 0 local page_count = tonumber(self.server_page_count) or 1 local first_index = tonumber(self.server_first_index) or 0 local last_index = tonumber(self.server_last_index) or 0 local page_sizes = self.server_page_sizes or {} local base_url = self.server_base_url or "" local function page_url(target_page, target_size) return string.format( "%s?server_page=%d&server_page_size=%d", base_url, target_page, target_size ) end function render_titles() if not has_titles then return end %>><% local i, k for i, k in ipairs(self.children) do if not k.optional then %>><% if k.titleref then %>" class="cbi-title-ref" href="<%=k.titleref%>"><% end write(k.title) if k.titleref then %><% end %><% end end if self.sortable or self.extedit or self.addremove then %><% end %><% rowcnt = rowcnt + 1 end function render_descriptions() if not has_descriptions then return end %><% local i, k for i, k in ipairs(self.children) do if not k.optional then %>><% write(k.description) %><% end end if self.sortable or self.extedit or self.addremove then %><% end %><% rowcnt = rowcnt + 1 end function render_pager() if total == 0 then return end %>
<%=string.format(translate("Showing %d-%d of %d nodes"), first_index, last_index, total)%> <% if page_count > 1 then %> <% if page > 1 then %> <%:Prev%> <% end %> <% for current = 1, page_count do %> <% if current == page then %> <%=current%> <% else %> <%=current%> <% end %> <% end %> <% if page < page_count then %> <%:Next%> <% end %> <% end %> <%:Per page%>: <% for _, size in ipairs(page_sizes) do %> <% local label = size == 0 and translate("All") or tostring(size) local selected = size == page_size %> <% if selected then %> <%=label%> <% else %> <%=label%> <% end %> <% end %>
<% end -%>
<% if self.title and #self.title > 0 then -%>

<%=self.title%>

<%- end %> <%- if self.sortable then -%> <%- end -%>
<%=self.description%>
<% render_pager() %> <%- render_titles() render_descriptions() local isempty, section, i, k = true, nil, nil for i, k in ipairs(self:cfgsections()) do isempty = false section = k local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k) local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true) local colorclass = (self.extedit or self.rowcolors) and rowstyle() or "" local scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" } -%> > <%- local node for k, node in ipairs(self.children) do if not node.optional then node:render(section, scope or {}) end end -%> <%- if self.sortable or self.extedit or self.addremove then -%> <%- end -%> <%- end -%> <%- if isempty then -%> <%- end -%>
<% if self.extedit then -%> onclick="location.href='<%=self.extedit:format(section)%>'" <%- elseif type(self.extedit) == "function" then %> onclick="location.href='<%=self:extedit(section)%>'" <%- end %> alt="<%:Edit%>" title="<%:Edit%>" /> <% end; if self.addremove then %> ', { sid: sid }, function(x, result) { result = result || {}; if (result.ret == 1) { window.location.reload(); return; } }); return false; " /> <%- end -%>
<%:This section contains no values yet%>
<% render_pager() %> <% if self.error then %>
<% end %> <%- if self.addremove then -%> <% if self.template_addremove then include(self.template_addremove) else -%>
<% if self.anonymous then %> <% else %> <% if self.invalid_cts then -%>
<%:Invalid%>
<%- end %>
<% end %>
<%- end %> <%- end -%>