2008-08-13 14:09:33 +00:00
< %-
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
2011-01-13 20:02:16 +00:00
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
2008-07-07 22:00:56 +00:00
-%>
2008-07-12 16:46:10 +00:00
2008-07-20 15:16:13 +00:00
<!-- tblsection -->
2008-08-14 01:31:17 +00:00
< fieldset class = "cbi-section" id = "cbi-<%=self.config%>-<%=self.sectiontype%>" >
2008-08-14 01:33:48 +00:00
< % if self.title and #self.title > 0 then -%>
< legend > < %=self.title%>< / legend >
< %- end %>
2011-01-20 00:01:55 +00:00
< %- if self.sortable then -%>
< input type = "hidden" id = "cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name = "cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value = "" / >
< %- end -%>
2008-07-15 17:27:58 +00:00
< div class = "cbi-section-descr" > < %=self.description%>< / div >
< div class = "cbi-section-node" >
< %- local count = 0 -%>
< table class = "cbi-section-table" >
< tr class = "cbi-section-table-titles" >
2008-08-13 01:24:44 +00:00
< %- if not self.anonymous then -%>
2009-01-12 17:31:19 +00:00
< %- if self.sectionhead then -%>
< th class = "cbi-section-table-cell" > < %=self.sectionhead%>< / th >
< %- else -%>
< th >   < / th >
< %- end -%>
2008-08-13 01:24:44 +00:00
< %- end -%>
2008-08-13 18:01:30 +00:00
< %- for i, k in pairs(self.children) do if not k.optional then -%>
2011-01-13 20:02:16 +00:00
< th class = "cbi-section-table-cell" < % = width ( k ) % > >
2009-11-01 11:54:14 +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 -%>
2008-08-14 11:50:13 +00:00
< %-=k.title-%>
< %- if k.titleref then -%>< / a > < %- end -%>
< / th >
2011-01-20 00:19:05 +00:00
< %- count = count + 1; end; end; if self.sortable then -%>
< th class = "cbi-section-table-cell" > < %:Sort%>< / th >
< %- end; if self.extedit or self.addremove then -%>
2008-08-20 19:44:16 +00:00
< th class = "cbi-section-table-cell" >   < / th >
2008-07-15 17:27:58 +00:00
< %- count = count + 1; end -%>
< / tr >
< tr class = "cbi-section-table-descr" >
2008-08-13 01:24:44 +00:00
< %- if not self.anonymous then -%>
2009-01-12 17:31:19 +00:00
< %- if self.sectiondesc then -%>
< th class = "cbi-section-table-cell" > < %=self.sectiondesc%>< / th >
< %- else -%>
< th > < / th >
< %- end -%>
2008-08-13 01:24:44 +00:00
< %- end -%>
2008-08-13 18:01:30 +00:00
< %- for i, k in pairs(self.children) do if not k.optional then -%>
2011-01-13 20:02:16 +00:00
< th class = "cbi-section-table-cell" < % = width ( k ) % > >< %=k.description%>< / th >
2011-01-20 00:19:05 +00:00
< %- end; end; if self.sortable then -%>
< th class = "cbi-section-table-cell" > < / th >
< %- end; if self.extedit or self.addremove then -%>
2008-08-13 18:12:47 +00:00
< th class = "cbi-section-table-cell" > < / th >
2008-07-15 17:27:58 +00:00
< %- end -%>
< / tr >
2008-07-20 01:34:05 +00:00
< %- local isempty = true
for i, k in ipairs(self:cfgsections()) do
2008-07-15 17:27:58 +00:00
section = k
2008-07-20 15:16:13 +00:00
isempty = false
2008-07-15 17:27:58 +00:00
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
2008-08-14 20:33:30 +00:00
< tr class = "cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id = "cbi-<%=self.config%>-<%=section%>" >
2008-08-13 01:24:44 +00:00
< % if not self.anonymous then -%>
2010-03-06 19:10:30 +00:00
< th > < h3 > < %=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%>< / h3 > < / th >
2008-08-13 01:24:44 +00:00
< %- end %>
2008-08-13 18:01:30 +00:00
< %-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
2011-01-20 00:01:55 +00:00
< %- if self.sortable then -%>
2012-02-15 15:27:03 +00:00
< td class = "cbi-section-table-cell" >
2012-02-14 15:08:12 +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%>" / >
2011-01-20 00:01:55 +00:00
< / td >
< %- end -%>
2008-08-13 01:24:44 +00:00
< %- if self.extedit or self.addremove then -%>
2012-02-15 15:27:03 +00:00
< td class = "cbi-section-table-cell" >
2008-08-13 01:24:44 +00:00
< %- if self.extedit then -%>
2012-02-15 15:13:27 +00:00
< input class = "cbi-button cbi-button-edit" type = "button" value = "<%:Edit%>"
2012-02-14 14:11:57 +00:00
< %- if type(self.extedit) == "string" then
2012-02-15 22:08:51 +00:00
%> onclick="location.href='< %=self.extedit:format(section)%>'"
2012-02-14 14:11:57 +00:00
< %- elseif type(self.extedit) == "function" then
2012-02-15 22:08:51 +00:00
%> onclick="location.href='< %=self:extedit(section)%>'"
2012-02-14 14:11:57 +00:00
< %- end
2012-02-15 15:13:27 +00:00
%> alt="< %:Edit%>" title="< %:Edit%>" />
2008-08-13 01:24:44 +00:00
< %- end; if self.addremove then %>
2012-02-15 22:08:51 +00:00
< 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%>" / >
2008-08-13 01:24:44 +00:00
< %- end -%>
< / td >
< %- end -%>
2008-07-15 17:27:58 +00:00
< / tr >
< %- end -%>
2008-07-20 15:16:13 +00:00
2008-07-20 01:34:05 +00:00
< %- if isempty then -%>
< tr class = "cbi-section-table-row" >
2009-10-31 15:54:11 +00:00
< td colspan = "<%=count%>" > < em > < br / > < %:This section contains no values yet%>< / em > < / td >
2008-07-20 01:34:05 +00:00
< / tr >
< %- end -%>
2008-08-13 01:24:44 +00:00
< / table >
2008-09-05 23:21:37 +00:00
< % if self.error then %>
< div class = "cbi-section-error" >
2008-09-06 22:37:56 +00:00
< ul > < % for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
2009-08-13 17:14:25 +00:00
< li > < %=pcdata(e):gsub("\n","< br / > ")%>< / li >
2008-09-06 22:37:56 +00:00
< %- end end %>< / ul >
2008-09-05 23:21:37 +00:00
< / div >
< % end %>
2008-09-08 00:34:27 +00:00
< %- if self.addremove then -%>
2008-10-10 11:47:32 +00:00
< % if self.template_addremove then include(self.template_addremove) else -%>
2008-10-20 19:02:26 +00:00
< div class = "cbi-section-create cbi-tblsection-create" >
2008-10-10 11:47:32 +00:00
< % if self.anonymous then %>
2011-10-09 20:14:25 +00:00
< input class = "cbi-button cbi-button-add" type = "submit" value = "<%:Add%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title = "<%:Add%>" / >
2008-10-10 11:47:32 +00:00
< % else %>
< % if self.invalid_cts then -%>< div class = "cbi-section-error" > < % end %>
2011-10-09 20:14:25 +00:00
< input type = "text" class = "cbi-section-create-name" id = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" / >
< script type = "text/javascript" > cbi _validate _field ( 'cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>' , true , 'uciname' ) ; < / script >
2010-10-21 20:51:32 +00:00
< input class = "cbi-button cbi-button-add" type = "submit" onclick = "this.form.cbi_state='add-section'; return true" value = "<%:Add%>" title = "<%:Add%>" / >
2008-10-10 11:47:32 +00:00
< % if self.invalid_cts then -%>
2009-10-31 15:54:11 +00:00
< br / > < %:Invalid%>< / div >
2008-10-10 11:47:32 +00:00
< %- end %>
< % end %>
< / div >
< %- end %>
2008-09-08 00:34:27 +00:00
< %- end -%>
2008-07-15 17:27:58 +00:00
< / div >
2008-08-14 01:31:17 +00:00
< / fieldset >
2008-07-20 15:16:13 +00:00
<!-- /tblsection -->