libs: merge libs/cbi into libs/web
[project/luci.git] / libs / web / luasrc / view / cbi / tblsection.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 -%>
15 <%-
16 local rowcnt = 1
17 function rowstyle()
18 rowcnt = rowcnt + 1
19 return (rowcnt % 2) + 1
20 end
21 -%>
22
23 <!-- tblsection -->
24 <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
25 <% if self.title and #self.title > 0 then -%>
26 <legend><%=self.title%></legend>
27 <%- end %>
28 <div class="cbi-section-descr"><%=self.description%></div>
29 <div class="cbi-section-node">
30 <%- local count = 0 -%>
31 <table class="cbi-section-table">
32 <tr class="cbi-section-table-titles">
33 <%- if not self.anonymous then -%>
34 <%- if self.sectionhead then -%>
35 <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
36 <%- else -%>
37 <th>&#160;</th>
38 <%- end -%>
39 <%- end -%>
40 <%- for i, k in pairs(self.children) do if not k.optional then -%>
41 <th class="cbi-section-table-cell">
42 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
43 <%-=k.title-%>
44 <%- if k.titleref then -%></a><%- end -%>
45 </th>
46 <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
47 <th class="cbi-section-table-cell">&#160;</th>
48 <%- count = count + 1; end -%>
49 </tr>
50 <tr class="cbi-section-table-descr">
51 <%- if not self.anonymous then -%>
52 <%- if self.sectiondesc then -%>
53 <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
54 <%- else -%>
55 <th></th>
56 <%- end -%>
57 <%- end -%>
58 <%- for i, k in pairs(self.children) do if not k.optional then -%>
59 <th class="cbi-section-table-cell"><%=k.description%></th>
60 <%- end; end; if self.extedit or self.addremove then -%>
61 <th class="cbi-section-table-cell"></th>
62 <%- end -%>
63 </tr>
64 <%- local isempty = true
65 for i, k in ipairs(self:cfgsections()) do
66 section = k
67 isempty = false
68 scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
69 -%>
70 <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
71 <% if not self.anonymous then -%>
72 <th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
73 <%- end %>
74
75
76 <%-
77 for k, node in ipairs(self.children) do
78 if not node.optional then
79 node:render(section, scope or {})
80 end
81 end
82 -%>
83
84 <%- if self.extedit or self.addremove then -%>
85 <td class="cbi-section-table-cell">
86 <%- if self.extedit then -%>
87 <a href="
88 <%- if type(self.extedit) == "string" then -%>
89 <%=self.extedit:format(section)%>
90 <%- elseif type(self.extedit) == "function" then -%>
91 <%=self:extedit(section)%>
92 <%- end -%>
93 " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
94 <%- end; if self.addremove then %>
95 <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
96 <%- end -%>
97 </td>
98 <%- end -%>
99 </tr>
100 <%- end -%>
101
102 <%- if isempty then -%>
103 <tr class="cbi-section-table-row">
104 <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
105 </tr>
106 <%- end -%>
107 </table>
108
109 <% if self.error then %>
110 <div class="cbi-section-error">
111 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
112 <li><%=pcdata(e):gsub("\n","<br />")%></li>
113 <%- end end %></ul>
114 </div>
115 <% end %>
116
117 <%- if self.addremove then -%>
118 <% if self.template_addremove then include(self.template_addremove) else -%>
119 <div class="cbi-section-create cbi-tblsection-create">
120 <% if self.anonymous then %>
121 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
122 <% else %>
123 <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
124 <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
125 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
126 <% if self.invalid_cts then -%>
127 <br /><%:Invalid%></div>
128 <%- end %>
129 <% end %>
130 </div>
131 <%- end %>
132 <%- end -%>
133 </div>
134 </fieldset>
135 <!-- /tblsection -->