2018-01-23 14:36:03 +00:00
< %-
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
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
-%>
<!-- tblsection -->
< fieldset class = "cbi-section" id = "cbi-<%=self.config%>-<%=self.sectiontype%>" >
< % if self.title and #self.title > 0 then -%>
< legend > < %=self.title%>< / legend >
< %- end %>
< %- if self.sortable then -%>
< input type = "hidden" id = "cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name = "cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value = "" / >
< %- end -%>
< div class = "cbi-section-descr" > < %=self.description%>< / div >
< div class = "cbi-section-node" >
< %- local count = 0 -%>
2018-06-04 20:10:32 +00:00
< div class = "table cbi-section-table" >
< div class = "tr cbi-section-table-titles" >
2018-01-23 14:36:03 +00:00
< %- if not self.anonymous then -%>
< %- if self.sectionhead then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" > < %=self.sectionhead%>< / div >
2018-01-23 14:36:03 +00:00
< %- else -%>
2018-06-04 20:10:32 +00:00
< div class = "th" >   < / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
2018-05-09 13:20:50 +00:00
< %- count = count +1; end -%>
2018-01-23 14:36:03 +00:00
< %- for i, k in pairs(self.children) do if not k.optional then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" < % = width ( k ) % > >
2018-01-23 14:36:03 +00:00
< %- if k.titleref then -%>< a title = "<%=self.titledesc or translate('Go to relevant configuration page')%>" class = "cbi-title-ref" href = "<%=k.titleref%>" > < %- end -%>
< %-=k.title-%>
< %- if k.titleref then -%>< / a > < %- end -%>
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< %- count = count + 1; end; end; if self.sortable then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" > < %:Sort%>< / div >
2018-05-09 13:20:50 +00:00
< %- count = count + 1; end; if self.extedit or self.addremove then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" >   < / div >
2018-01-23 14:36:03 +00:00
< %- count = count + 1; end -%>
2018-06-04 20:10:32 +00:00
< / div >
< div class = "tr cbi-section-table-descr" >
2018-01-23 14:36:03 +00:00
< %- if not self.anonymous then -%>
< %- if self.sectiondesc then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" > < %=self.sectiondesc%>< / div >
2018-01-23 14:36:03 +00:00
< %- else -%>
2018-06-04 20:10:32 +00:00
< div class = "th" > < / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
< %- end -%>
< %- for i, k in pairs(self.children) do if not k.optional then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" < % = width ( k ) % > >< %=k.description%>< / div >
2018-01-23 14:36:03 +00:00
< %- end; end; if self.sortable then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" > < / div >
2018-01-23 14:36:03 +00:00
< %- end; if self.extedit or self.addremove then -%>
2018-06-04 20:10:32 +00:00
< div class = "th cbi-section-table-cell" > < / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< %- local isempty = true
for i, k in ipairs(self:cfgsections()) do
section = k
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
2018-06-04 20:10:32 +00:00
< div class = "tr cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id = "cbi-<%=self.config%>-<%=section%>" >
2018-01-23 14:36:03 +00:00
< % if not self.anonymous then -%>
2018-06-04 20:10:32 +00:00
< div class = "th" > < h3 > < %=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%>< / h3 > < / div >
2018-01-23 14:36:03 +00:00
< %- end %>
< %-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
< %- if self.sortable then -%>
2018-06-04 20:10:32 +00:00
< div class = "td cbi-section-table-cell" >
2018-01-23 14:36:03 +00:00
< input class = "cbi-button cbi-button-up" type = "button" value = "" onclick = "return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt = "<%:Move up%>" title = "<%:Move up%>" / >
< input class = "cbi-button cbi-button-down" type = "button" value = "" onclick = "return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt = "<%:Move down%>" title = "<%:Move down%>" / >
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
< %- if self.extedit or self.addremove then -%>
2018-06-04 20:10:32 +00:00
< div class = "td cbi-section-table-cell" >
2018-01-23 14:36:03 +00:00
< %- if self.extedit then -%>
< input class = "cbi-button cbi-button-edit" type = "button" value = "<%:Edit%>"
< %- if type(self.extedit) == "string" 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 %>
< input class = "cbi-button cbi-button-remove" type = "submit" value = "<%:Delete%>" onclick = "this.form.cbi_state='del-section'; return true" name = "cbi.rts.<%=self.config%>.<%=k%>" alt = "<%:Delete%>" title = "<%:Delete%>" / >
< %- end -%>
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
< %- if isempty then -%>
2018-06-04 20:10:32 +00:00
< div class = "tr cbi-section-table-row" >
< div class = "td" colspan = "<%=count%>" > < em > < br / > < %:This section contains no values yet%>< / em > < / div >
< / div >
2018-01-23 14:36:03 +00:00
< %- end -%>
2018-06-04 20:10:32 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< % if self.error then %>
< div class = "cbi-section-error" >
< ul > < % for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
< li > < %=pcdata(e):gsub("\n","< br / > ")%>< / li >
< %- end end %>< / ul >
< / div >
< % end %>
< %- if self.addremove then -%>
< % if self.template_addremove then include(self.template_addremove) else -%>
< div class = "cbi-section-create cbi-tblsection-create" >
< % if self.anonymous then %>
< input class = "cbi-button cbi-button-add" type = "submit" value = "<%:Add%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title = "<%:Add%>" / >
< % else %>
< % if self.invalid_cts then -%>< div class = "cbi-section-error" > < % end %>
< input type = "text" class = "cbi-section-create-name" id = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type = "uciname" data-optional = "true" / >
< input class = "cbi-button cbi-button-add" type = "submit" onclick = "this.form.cbi_state='add-section'; return true" value = "<%:Add%>" title = "<%:Add%>" / >
< % if self.invalid_cts then -%>
< br / > < %:Invalid%>< / div >
< %- end %>
< % end %>
< / div >
< %- end %>
< %- end -%>
< / div >
< / fieldset >
<!-- /tblsection -->