From: Jo-Philipp Wich Date: Wed, 18 Jul 2018 09:36:53 +0000 (+0200) Subject: luci-base: rework simpleform template X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=bc562294b9a5a2867b8b6e1cb21d9a2d4a2b8b59;p=project%2Fluci.git 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 --- 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 %> -
-
- - -
-<% end %> -
- <% if self.title and #self.title > 0 then %>

<%=self.title%>

<% end %> - <% if self.description and #self.description > 0 then %>
<%=self.description%>
<% end %> - <% self:render_children() %> -
-<%- if self.message then %> -
<%=self.message%>
-<%- end %> -<%- if self.errmessage then %> -
<%=self.errmessage%>
-<%- end %> -<% if not self.embedded then %> -
-<%- - if type(self.hidden) == "table" then - for k, v in pairs(self.hidden) do --%> - -<%- +<% + if not self.embedded then + %> + + <% + end + + %>
<% + + if self.title and #self.title > 0 then + %>

<%=self.title%>

<% + end + + if self.description and #self.description > 0 then + %>
<%=self.description%>
<% + end + + self:render_children() + + %>
<% + + if self.message then + %>
<%=self.message%>
<% + end + + if self.errmessage then + %>
<%=self.errmessage%>
<% + end + + if not self.embedded then + if type(self.hidden) == "table" then + local k, v + for k, v in pairs(self.hidden) do + %><% + 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 + %>
<% + + if display_back then + %> <% + end + + if display_cancel then + local label = pcdata(self.cancel or translate("Cancel")) + %> <% + end + + if display_skip then + %> <% + end + + if display_submit then + local label = pcdata(self.submit or translate("Submit")) + %> <% + end + + if display_reset then + local label = pcdata(self.reset or translate("Reset")) + %> <% + end + + %>
<% + end + + %><% end %> -<% if redirect then %> - -<% end %> -<%- if self.cancel ~= false and self.on_cancel then %> - -<% end %> -<%- if self.flow and self.flow.skip then %> - -<% end %> -<%- if self.submit ~= false then %> - -<% end %> -<%- if self.reset ~= false then %> - -<% end %> -
- -<% end %>