* luci/libs/cbi: implement file browse fields
[project/luci.git] / libs / cbi / luasrc / view / cbi / ucisection.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 <% self:render_children(section, scope or {}) %>
17
18 <% if self.error and self.error[section] then -%>
19         <div class="cbi-section-error">
20                 <ul><% for _, e in ipairs(self.error[section]) do %><li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li><% end %></ul>
21         </div>
22 <%- end %>
23
24 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
25         <div class="cbi-optionals">
26                 <% if self.dynamic then %>
27                         <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
28                         <% if self.optionals[section] and #self.optionals[section] > 0 then %>
29                         <script type="text/javascript">
30                                 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
31                                 <%-
32                                         for i, val in pairs(self.optionals[section]) do
33                                 -%>
34                                         <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
35                                         <%-if next(self.optionals[section], i) then-%>,<%-end-%>
36                                 <%-
37                                         end
38                                 -%>
39                                 }, '', '<%-:cbi_manual-%>');
40                         </script>
41                         <% end %>
42                 <% else %>
43                 <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
44                         <option><%:cbi_addopt%></option>
45                         <% for key, val in pairs(self.optionals[section]) do -%>
46                                 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
47                         <%- end %>
48                 </select>
49                 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
50                         <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
51                         cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
52                 <%-
53                         for k,v in pairs(d.deps) do
54                 -%>
55                         <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
56                         <%-if next(d.deps, k) then-%>,<%-end-%>
57                 <%-
58                         end
59                 -%>
60                         });
61                 <%- end %><% end %>
62                 <% end %></script>
63         <% end %>
64                 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" />
65         </div>
66 <% end %>