libs/web: add missing cells to tblsection template
[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 function width(o)
23         if o.width then
24                 if type(o.width) == 'number' then
25                         return ' style="width:%dpx"' % o.width
26                 end
27                 return ' style="width:%s"' % o.width
28         end
29         return ''
30 end
31 -%>
32
33 <!-- tblsection -->
34 <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
35         <% if self.title and #self.title > 0 then -%>
36                 <legend><%=self.title%></legend>
37         <%- end %>
38         <%- if self.sortable then -%>
39                 <input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
40         <%- end -%>
41         <div class="cbi-section-descr"><%=self.description%></div>
42         <div class="cbi-section-node">
43                 <%- local count = 0 -%>
44                 <table class="cbi-section-table">
45                         <tr class="cbi-section-table-titles">
46                         <%- if not self.anonymous then -%>
47                                 <%- if self.sectionhead then -%>
48                                         <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
49                                 <%- else -%>
50                                         <th>&#160;</th>
51                                 <%- end -%>
52                         <%- end -%>
53                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
54                                 <th class="cbi-section-table-cell"<%=width(k)%>>
55                                 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
56                                         <%-=k.title-%>
57                                 <%- if k.titleref then -%></a><%- end -%>
58                                 </th>
59                         <%- count = count + 1; end; end; if self.sortable then -%>
60                                 <th class="cbi-section-table-cell"><%:Sort%></th>
61                         <%- end; if self.extedit or self.addremove then -%>
62                                 <th class="cbi-section-table-cell">&#160;</th>
63                         <%- count = count + 1; end -%>
64                         </tr>
65                         <tr class="cbi-section-table-descr">
66                         <%- if not self.anonymous then -%>
67                                 <%- if self.sectiondesc then -%>
68                                         <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
69                                 <%- else -%>
70                                         <th></th>
71                                 <%- end -%>
72                         <%- end -%>
73                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
74                                 <th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
75                         <%- end; end; if self.sortable then -%>
76                                 <th class="cbi-section-table-cell"></th>
77                         <%- end; if self.extedit or self.addremove then -%>
78                                 <th class="cbi-section-table-cell"></th>
79                         <%- end -%>
80                         </tr>
81                         <%- local isempty = true
82                             for i, k in ipairs(self:cfgsections()) do
83                                         section = k
84                                         isempty = false
85                                         scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
86                         -%>
87                         <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
88                                 <% if not self.anonymous then -%>
89                                         <th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
90                                 <%- end %>
91
92
93                                 <%-
94                                         for k, node in ipairs(self.children) do
95                                                 if not node.optional then
96                                                         node:render(section, scope or {})
97                                                 end
98                                         end
99                                 -%>
100
101                                 <%- if self.sortable then -%>
102                                         <td class="cbi-section-table-cell" style="width:50px">
103                                                 <a href="#" onclick="return cbi_row_swap(this, true,  'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>"><img src="<%=resource%>/cbi/up.gif" alt="<%:Move up%>" /></a>
104                                                 <a href="#" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>"><img src="<%=resource%>/cbi/down.gif" alt="<%:Move down%>" /></a>
105                                         </td>
106                                 <%- end -%>
107
108                                 <%- if self.extedit or self.addremove then -%>
109                                         <td class="cbi-section-table-cell" style="width:50px">
110                                                 <%- if self.extedit then -%>
111                                                         <a href="
112                                                         <%- if type(self.extedit) == "string" then -%>
113                                                                 <%=self.extedit:format(section)%>
114                                                         <%- elseif type(self.extedit) == "function" then -%>
115                                                                 <%=self:extedit(section)%>
116                                                         <%- end -%>
117                                                         " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
118                                                 <%- end; if self.addremove then %>
119                                                         <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" />
120                                                 <%- end -%>
121                                         </td>
122                                 <%- end -%>
123                         </tr>
124                         <%- end -%>
125
126                         <%- if isempty then -%>
127                         <tr class="cbi-section-table-row">
128                                 <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
129                         </tr>
130                         <%- end -%>
131                 </table>
132
133                 <% if self.error then %>
134                         <div class="cbi-section-error">
135                                 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
136                                         <li><%=pcdata(e):gsub("\n","<br />")%></li>
137                                 <%- end end %></ul>
138                         </div>
139                 <% end %>
140
141                 <%- if self.addremove then -%>
142                         <% if self.template_addremove then include(self.template_addremove) else -%>
143                         <div class="cbi-section-create cbi-tblsection-create">
144                                 <% if self.anonymous then %>
145                                         <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
146                                 <% else %>
147                                         <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
148                                         <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
149                                         <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>', true, 'uciname');</script>
150                                         <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
151                                         <% if self.invalid_cts then -%>
152                                                 <br /><%:Invalid%></div>
153                                         <%- end %>
154                                 <% end %>
155                         </div>
156                         <%- end %>
157                 <%- end -%>
158         </div>
159 </fieldset>
160 <!-- /tblsection -->