2008-07-07 22:00:56 +00:00
< %#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth < steven @ midlink . org >
Copyright 2008 Jo-Philipp Wich < xm @ leipzig . freifunk . net >
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
2008-08-13 14:09:33 +00:00
-%>
< %-
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
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 %>
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 -%>
2008-08-14 11:50:13 +00:00
< th class = "cbi-section-table-cell" >
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 >
2008-08-13 18:01:30 +00:00
< %- count = count + 1; end; 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 -%>
2008-07-15 17:27:58 +00:00
< th class = "cbi-section-table-cell" > < %=k.description%>< / th >
2008-08-13 18:01:30 +00:00
< %- end; 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
-%>
2008-08-13 01:24:44 +00:00
< %- if self.extedit or self.addremove then -%>
< td class = "cbi-section-table-cell" >
< %- if self.extedit then -%>
2008-08-18 00:38:18 +00:00
< a href = "
< %- if type(self.extedit) == "string" then -%>
< %=self.extedit:format(section)%>
< %- elseif type(self.extedit) == "function" then -%>
< %=self:extedit(section)%>
< %- end -%>
2009-10-31 15:54:11 +00:00
" title="< %:Edit%>">< img style = "border: none" src = "<%=resource%>/cbi/edit.gif" alt = "<%:Edit%>" / > < / a >
2008-08-13 01:24:44 +00:00
< %- end; if self.addremove then %>
2010-10-21 20:51:32 +00:00
< input type = "image" value = "<%:Delete%>" onclick = "this.form.cbi_state='del-section'; return true" name = "cbi.rts.<%=self.config%>.<%=k%>" alt = "<%:Delete%>" title = "<%:Delete%>" src = "<%=resource%>/cbi/remove.gif" / >
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 %>
2009-10-31 15:54:11 +00:00
< input class = "cbi-button cbi-button-add" type = "submit" value = "<%:Add%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title = "<%:Add%>" / >
2008-10-10 11:47:32 +00:00
< % else %>
< % if self.invalid_cts then -%>< div class = "cbi-section-error" > < % end %>
2010-12-05 17:37:59 +00:00
< input type = "text" class = "cbi-section-create-name" id = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>" name = "cbi.cts.<%=self.config%>.<%=self.sectiontype%>" / >
< script type = "text/javascript" > cbi _validate _field ( 'cbi.cts.<%=self.config%>.<%=self.sectiontype%>' , 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 -->