luci-base: rework simpleform template
- Ensure that pressing enter in the form triggers the submit action and not a cbi skip or cancel - Hide page actions when empty - Cleanup code Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
7b43e81c9b
commit
bc562294b9
1 changed files with 72 additions and 50 deletions
|
@ -1,55 +1,77 @@
|
||||||
<% if not self.embedded then %>
|
<%
|
||||||
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
|
if not self.embedded then
|
||||||
<div>
|
%><form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
|
||||||
<input type="hidden" name="token" value="<%=token%>" />
|
<input type="hidden" name="token" value="<%=token%>" />
|
||||||
<input type="hidden" name="cbi.submit" value="1" />
|
<input type="hidden" name="cbi.submit" value="1" /><%
|
||||||
</div>
|
end
|
||||||
<% end %>
|
|
||||||
<div class="cbi-map" id="cbi-<%=self.config%>">
|
%><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 %>
|
if self.title and #self.title > 0 then
|
||||||
<% self:render_children() %>
|
%><h2 name="content"><%=self.title%></h2><%
|
||||||
</div>
|
end
|
||||||
<%- if self.message then %>
|
|
||||||
<div><%=self.message%></div>
|
if self.description and #self.description > 0 then
|
||||||
<%- end %>
|
%><div class="cbi-map-descr"><%=self.description%></div><%
|
||||||
<%- if self.errmessage then %>
|
end
|
||||||
<div class="error"><%=self.errmessage%></div>
|
|
||||||
<%- end %>
|
self:render_children()
|
||||||
<% if not self.embedded then %>
|
|
||||||
<div class="cbi-page-actions">
|
%></div><%
|
||||||
<%-
|
|
||||||
if type(self.hidden) == "table" then
|
if self.message then
|
||||||
for k, v in pairs(self.hidden) do
|
%><div class="alert-message notice"><%=self.message%></div><%
|
||||||
-%>
|
end
|
||||||
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
|
|
||||||
<%-
|
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
|
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
|
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>
|
<script type="text/javascript">cbi_init();</script>
|
||||||
|
|
Loading…
Reference in a new issue