CBI-UVL Validation Integration part #1
[project/luci.git] / libs / cbi / 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                                 <th>&#160;</th>
35                         <%- end -%>
36                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
37                                 <th class="cbi-section-table-cell">
38                                 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('cbi_gorel')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
39                                         <%-=k.title-%>
40                                 <%- if k.titleref then -%></a><%- end -%>
41                                 </th>
42                         <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
43                                 <th class="cbi-section-table-cell">&#160;</th>
44                         <%- count = count + 1; end -%>
45                         </tr>
46                         <tr class="cbi-section-table-descr">
47                         <%- if not self.anonymous then -%>
48                                 <th></th>
49                         <%- end -%>
50                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
51                                 <th class="cbi-section-table-cell"><%=k.description%></th>
52                         <%- end; end; if self.extedit or self.addremove then -%>
53                                 <th class="cbi-section-table-cell"></th>
54                         <%- end -%>
55                         </tr>
56                         <%- local isempty = true
57                             for i, k in ipairs(self:cfgsections()) do
58                                         section = k
59                                         isempty = false
60                                         scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
61                         -%>
62                         <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
63                                 <% if not self.anonymous then -%>
64                                         <th><h3><%=k%></h3></th>
65                                 <%- end %>
66
67
68                                 <%-
69                                         for k, node in ipairs(self.children) do
70                                                 if not node.optional then
71                                                         node:render(section, scope or {})
72                                                 end
73                                         end
74                                 -%>
75
76                                 <%- if self.extedit or self.addremove then -%>
77                                         <td class="cbi-section-table-cell">
78                                                 <%- if self.extedit then -%>
79                                                         <a href="
80                                                         <%- if type(self.extedit) == "string" then -%>
81                                                                 <%=self.extedit:format(section)%>
82                                                         <%- elseif type(self.extedit) == "function" then -%>
83                                                                 <%=self:extedit(section)%>
84                                                         <%- end -%>
85                                                         " title="<%:edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:edit%>" /></a>
86                                                 <%- end; if self.addremove then %>
87                                                         <input type="image" value="<%:cbi_del%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:cbi_del%>" title="<%:cbi_del%>" src="<%=resource%>/cbi/remove.gif" />
88                                                 <%- end -%>
89                                         </td>
90                                 <%- end -%>
91                         </tr>
92                         <% if self.tag_deperror[section] or self.tag_invalid[section] or self.tag_error[section] then %>
93                                 <tr class="cbi-section-table-row">
94                                         <td colspan="<%=count%>">
95                                 <%- if self.tag_deperror[section] then -%>
96                                         <div class="cbi-error"><%:cbi_deperror%></div>
97                                 <%- elseif self.tag_invalid[section] then -%>
98                                         <div class="cbi-error"><%:cbi_invalid_section%></div>
99                                 <%- elseif self.tag_error[section] then -%>
100                                         <div class="cbi-error"><%=self.tag_error[section]%></div>
101                                 <%- end -%>
102                                         </td>
103                                 </tr>
104                         <% end %>
105                         <%- end -%>
106
107                         <%- if isempty then -%>
108                         <tr class="cbi-section-table-row">
109                                 <td colspan="<%=count%>"><em><br /><%:cbi_sectempty%></em></td>
110                         </tr>
111                         <%- end -%>
112                 </table>
113                         <%- if self.addremove then -%>
114                         <div class="cbi-section-table-row">
115                                 <td colspan="<%=count%>" class="cbi-section-table-optionals">
116                                         <div class="cbi-section-create">
117                                                 <% if self.anonymous then %>
118                                                         <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:cbi_add%>" />
119                                                 <% else %>
120                                                         <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
121                                                         <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" title="<%:cbi_add%>" />
122                                                 <% end %>
123
124                                                 <% if self.err_invalid then %>
125                                                         <div class="cbi-error"><%:cbi_invalid%></div>
126                                                 <% end %>
127                                         </div>
128                                 </td>
129                         </div>
130                         <%- end -%>
131         </div>
132 </fieldset>
133 <!-- /tblsection -->