summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r--modules/luci-base/luasrc/view/cbi/footer.htm56
-rw-r--r--modules/luci-base/luasrc/view/cbi/simpleform.htm122
-rw-r--r--modules/luci-base/luasrc/view/cbi/tblsection.htm126
3 files changed, 204 insertions, 100 deletions
diff --git a/modules/luci-base/luasrc/view/cbi/footer.htm b/modules/luci-base/luasrc/view/cbi/footer.htm
index 5f939b6469..ed632202ce 100644
--- a/modules/luci-base/luasrc/view/cbi/footer.htm
+++ b/modules/luci-base/luasrc/view/cbi/footer.htm
@@ -1,23 +1,39 @@
- <%- if pageaction then -%>
- <div class="cbi-page-actions">
- <% if redirect and not flow.hidebackbtn then %>
- <input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
- <% end %>
-
- <% if flow.skip then %>
- <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
- <% end %>
- <% if not autoapply and not flow.hideapplybtn then %>
- <input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:Save & Apply%>" />
- <% end %>
- <% if not flow.hidesavebtn then %>
- <input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" />
- <% end %>
- <% if not flow.hideresetbtn then %>
- <input class="cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'" />
- <% end %>
- </div>
- <%- end -%>
+<%
+ local display_back = (redirect and not flow.hidebackbtn)
+ local display_skip = (flow.skip)
+ local display_apply = (not autoapply and not flow.hideapplybtn)
+ local display_save = (not flow.hidesavebtn)
+ local display_reset = (not flow.hideresetbtn)
+
+ if pageaction and
+ (display_back or display_skip or display_apply or display_save or display_reset)
+ then
+ %><div class="cbi-page-actions"><%
+
+ if display_back then
+ %><input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" /> <%
+ end
+
+ if display_skip then
+ %><input class="cbi-button cbi-button-skip" type="button" value="<%:Skip%>" onclick="cbi_submit(this, 'cbi.skip')" /> <%
+ end
+
+ if display_apply then
+ %><input class="cbi-button cbi-button-apply" type="button" value="<%:Save & Apply%>" onclick="cbi_submit(this, 'cbi.apply')" /> <%
+ end
+
+ if display_save then
+ %><input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" /> <%
+ end
+
+ if display_reset then
+ %><input class="cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'" /> <%
+ end
+
+ %></div><%
+ end
+%>
+
</form>
<script type="text/javascript">cbi_init();</script>
diff --git a/modules/luci-base/luasrc/view/cbi/simpleform.htm b/modules/luci-base/luasrc/view/cbi/simpleform.htm
index 5069e9f407..3e10724ec5 100644
--- a/modules/luci-base/luasrc/view/cbi/simpleform.htm
+++ b/modules/luci-base/luasrc/view/cbi/simpleform.htm
@@ -1,55 +1,77 @@
-<% if not self.embedded then %>
-<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
- <div>
- <input type="hidden" name="token" value="<%=token%>" />
- <input type="hidden" name="cbi.submit" value="1" />
- </div>
-<% end %>
- <div class="cbi-map" id="cbi-<%=self.config%>">
- <% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
- <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
- <% self:render_children() %>
- </div>
-<%- if self.message then %>
- <div><%=self.message%></div>
-<%- end %>
-<%- if self.errmessage then %>
- <div class="error"><%=self.errmessage%></div>
-<%- end %>
-<% if not self.embedded then %>
- <div class="cbi-page-actions">
-<%-
- if type(self.hidden) == "table" then
- for k, v in pairs(self.hidden) do
--%>
- <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
-<%-
+<%
+ if not self.embedded then
+ %><form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
+ <input type="hidden" name="token" value="<%=token%>" />
+ <input type="hidden" name="cbi.submit" value="1" /><%
+ end
+
+ %><div class="cbi-map" id="cbi-<%=self.config%>"><%
+
+ if self.title and #self.title > 0 then
+ %><h2 name="content"><%=self.title%></h2><%
+ end
+
+ if self.description and #self.description > 0 then
+ %><div class="cbi-map-descr"><%=self.description%></div><%
+ end
+
+ self:render_children()
+
+ %></div><%
+
+ if self.message then
+ %><div class="alert-message notice"><%=self.message%></div><%
+ end
+
+ if self.errmessage then
+ %><div class="alert-message warning"><%=self.errmessage%></div><%
+ end
+
+ if not self.embedded then
+ if type(self.hidden) == "table" then
+ local k, v
+ for k, v in pairs(self.hidden) do
+ %><input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" /><%
+ end
end
+
+ local display_back = (redirect)
+ local display_cancel = (self.cancel ~= false and self.on_cancel)
+ local display_skip = (self.flow and self.flow.skip)
+ local display_submit = (self.submit ~= false)
+ local display_reset = (self.reset ~= false)
+
+ if display_back or display_cancel or display_skip or display_submit or display_reset then
+ %><div class="cbi-page-actions"><%
+
+ if display_back then
+ %><input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" /> <%
+ end
+
+ if display_cancel then
+ local label = pcdata(self.cancel or translate("Cancel"))
+ %><input class="cbi-button cbi-button-link" type="button" value="<%=label%>" onclick="cbi_submit(this, 'cbi.cancel')" /> <%
+ end
+
+ if display_skip then
+ %><input class="cbi-button cbi-button-neutral" type="button" value="<%:Skip%>" onclick="cbi_submit(this, 'cbi.skip')" /> <%
+ end
+
+ if display_submit then
+ local label = pcdata(self.submit or translate("Submit"))
+ %><input class="cbi-button cbi-button-save" type="submit" value="<%=label%>" /> <%
+ end
+
+ if display_reset then
+ local label = pcdata(self.reset or translate("Reset"))
+ %><input class="cbi-button cbi-button-reset" type="reset" value="<%=label%>" /> <%
+ end
+
+ %></div><%
+ end
+
+ %></form><%
end
%>
-<% if redirect then %>
- <input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
-<% end %>
-<%- if self.cancel ~= false and self.on_cancel then %>
- <input class="cbi-button cbi-button-link" type="submit" name="cbi.cancel" value="
- <%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
- " />
-<% end %>
-<%- if self.flow and self.flow.skip then %>
- <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
-<% end %>
-<%- if self.submit ~= false then %>
- <input class="cbi-button cbi-button-save" type="submit" value="
- <%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
- " />
-<% end %>
-<%- if self.reset ~= false then %>
- <input class="cbi-button cbi-button-reset" type="reset" value="
- <%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
- " />
-<% end %>
- </div>
-</form>
-<% end %>
<script type="text/javascript">cbi_init();</script>
diff --git a/modules/luci-base/luasrc/view/cbi/tblsection.htm b/modules/luci-base/luasrc/view/cbi/tblsection.htm
index 7067aa5876..9505f4ac4e 100644
--- a/modules/luci-base/luasrc/view/cbi/tblsection.htm
+++ b/modules/luci-base/luasrc/view/cbi/tblsection.htm
@@ -1,8 +1,13 @@
<%-
-local rowcnt = 1
+local rowcnt = 0
+
function rowstyle()
rowcnt = rowcnt + 1
- return (rowcnt % 2) + 1
+ if rowcnt % 2 == 0 then
+ return "cbi-rowstyle-1"
+ else
+ return "cbi-rowstyle-2"
+ end
end
function width(o)
@@ -15,54 +20,115 @@ function width(o)
return ''
end
+local has_titles = false
+local has_descriptions = false
+
local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
+local i, k
+for i, k in pairs(self.children) do
+ if not k.typename then
+ k.typename = k.template and k.template:gsub("^.+/", "") or ""
+ end
+
+ if not has_titles and k.title and #k.title > 0 then
+ has_titles = true
+ end
+
+ if not has_descriptions and k.description and #k.description > 0 then
+ has_descriptions = true
+ end
+end
+
+function render_titles()
+ if not has_titles then
+ return
+ end
+
+ %><div class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>><%
+
+ local i, k
+ for i, k in ipairs(self.children) do
+ if not k.optional then
+ %><div class="th cbi-section-table-cell"<%=
+ width(k) .. attr('data-type', k.typename) %>><%
+
+ if k.titleref then
+ %><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%
+ end
+
+ write(k.title)
+
+ if k.titleref then
+ %></a><%
+ end
+
+ %></div><%
+ end
+ end
+
+ if self.sortable or self.extedit or self.addremove then
+ %><div class="th cbi-section-table-cell cbi-section-actions"></div><%
+ end
+
+ %></div><%
+
+ rowcnt = rowcnt + 1
+end
+
+function render_descriptions()
+ if not has_descriptions then
+ return
+ end
+
+ %><div class="tr cbi-section-table-descr <%=anonclass%>"><%
+
+ local i, k
+ for i, k in ipairs(self.children) do
+ if not k.optional then
+ %><div class="th cbi-section-table-cell"<%=
+ width(k) .. attr("data-type", k.typename) %>><%
+
+ write(k.description)
+
+ %></div><%
+ end
+ end
+
+ if self.sortable or self.extedit or self.addremove then
+ %><div class="th cbi-section-table-cell cbi-section-actions"></div><%
+ end
+
+ %></div><%
+
+ rowcnt = rowcnt + 1
+end
+
-%>
<!-- tblsection -->
<div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
- <legend><%=self.title%></legend>
+ <h3><%=self.title%></h3>
<%- end %>
<%- if self.sortable then -%>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
- <%- local count = 0 -%>
<div class="table cbi-section-table">
- <div class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>>
- <%- for i, k in pairs(self.children) do if not k.optional then -%>
- <div class="th cbi-section-table-cell"<%=
- width(k) ..
- attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
- %>>
- <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
- <%-=k.title-%>
- <%- if k.titleref then -%></a><%- end -%>
- </div>
- <%- count = count + 1; end; end; if self.sortable or self.extedit or self.addremove then -%>
- <div class="th cbi-section-table-cell cbi-section-actions"></div>
- <%- count = count + 1; end -%>
- </div>
- <div class="tr cbi-section-table-descr <%=anonclass%>">
- <%- for i, k in pairs(self.children) do if not k.optional then -%>
- <div class="th cbi-section-table-cell"<%=
- width(k) ..
- attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
- %>><%=k.description%></div>
- <%- end; end; if self.sortable or self.extedit or self.addremove then -%>
- <div class="th cbi-section-table-cell cbi-section-actions"></div>
- <%- end -%>
- </div>
- <%- local isempty, section, i, k = true, nil, nil
+ <%-
+ render_titles()
+ render_descriptions()
+
+ local isempty, section, i, k = true, nil, nil
for i, k in ipairs(self:cfgsections()) do
isempty = false
section = k
local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname)
- local colorclass = (self.extedit or self.rowcolors) and " cbi-rowstyle-%d" % rowstyle() or ""
+ local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
local scope = {
valueheader = "cbi/cell_valueheader",
valuefooter = "cbi/cell_valuefooter"