Add luci
[librecmc/librecmc.git] / package / luci / modules / luci-base / luasrc / view / cbi / dropdown.htm
1 <%+cbi/valueheader%>
2
3 <%-
4         local selected = { }
5
6         if self.multiple then
7                 local val
8                 for val in luci.util.imatch(self:cfgvalue(section)) do
9                         selected[val] = true
10                 end
11         else
12                 selected[self:cfgvalue(section)] = true
13         end
14
15         if not next(selected) and self.default then
16                 selected[self.default] = true
17         end
18 -%>
19
20 <div class="cbi-dropdown"<%=
21         attr("name", cbid) ..
22         attr("display-items", self.display or self.size or 3) ..
23         attr("dropdown-items", self.dropdown or self.display or self.size or 5) ..
24         attr("placeholder", self.placeholder or translate("-- please select --")) ..
25         ifattr(self.multiple, "multiple", "multiple") ..
26         ifattr(self.optional or self.rmempty, "optional", "optional")
27 %>>
28         <ul>
29                 <% local i, key; for i, key in pairs(self.keylist) do %>
30                         <li<%=
31                                 attr("data-index", i) ..
32                                 attr("data-depends", self:deplist2json(section, self.deplist[i])) ..
33                                 attr("value", key) ..
34                                 ifattr(selected[key], "selected", "selected")
35                         %>>
36                                 <%=pcdata(self.vallist[i])%>
37                         </li>
38                 <% end %>
39         </ul>
40 </div>
41
42 <%+cbi/valuefooter%>