diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 20:49:31 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 20:49:31 +0100 |
commit | d5dff8f9a5ca85d197cbb6037f95053bc55941e5 (patch) | |
tree | eeb9271b96ba7b52bad777841ca4ebd452b1a2b0 /modules/luci-compat/luasrc/view/cbi/ucisection.htm | |
parent | 9e57fbb2c3f9c44cdf0a57e6fb9c1df32c84d52b (diff) |
treewide: move server side CBI support to luci-compat
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-compat/luasrc/view/cbi/ucisection.htm')
-rw-r--r-- | modules/luci-compat/luasrc/view/cbi/ucisection.htm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/luci-compat/luasrc/view/cbi/ucisection.htm b/modules/luci-compat/luasrc/view/cbi/ucisection.htm new file mode 100644 index 0000000000..8fa11d68f8 --- /dev/null +++ b/modules/luci-compat/luasrc/view/cbi/ucisection.htm @@ -0,0 +1,56 @@ +<%- + if type(self.hidden) == "table" then + for k, v in pairs(self.hidden) do +-%> + <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" /> +<%- + end + end +%> + +<% if self.tabs then %> + <%+cbi/tabcontainer%> +<% else %> + <% self:render_children(section, scope or {}) %> +<% end %> + +<% if self.error and self.error[section] then -%> + <div class="cbi-section-error" data-index="<%=#self.children + 1%>"> + <ul><% for _, e in ipairs(self.error[section]) do -%> + <li> + <%- if e == "invalid" then -%> + <%:One or more fields contain invalid values!%> + <%- elseif e == "missing" then -%> + <%:One or more required fields have no value!%> + <%- else -%> + <%=pcdata(e)%> + <%- end -%> + </li> + <%- end %></ul> + </div> +<%- end %> + +<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %> + <div class="cbi-optionals" data-index="<%=#self.children + 1%>"> + <%- + if self.dynamic then + local keys, vals, name, opt = { }, { } + for name, opt in pairs(self.optionals[section]) do + keys[#keys+1] = name + vals[#vals+1] = opt.title + end + -%> + <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-type="uciname" data-optional="true"<%= + ifattr(#keys > 0, "data-choices", luci.util.json_encode({keys, vals})) + %> /> + <%- else -%> + <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" data-optionals="true"> + <option><%: -- Additional Field -- %></option> + <% for key, val in pairs(self.optionals[section]) do -%> + <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>" data-index="<%=val.index%>" data-depends="<%=pcdata(val:deplist2json(section))%>"><%=striptags(val.title)%></option> + <%- end %> + </select> + <%- end -%> + <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" /> + </div> +<% end %> |