luci-base: fixed tabbed map when using NamedSection of same type

* fixed tabbed map when using NamedSection of same sectiontype
* add error message on which tab(s) the invalid/required fields are located

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
Christian Schoenebeck 2016-02-08 21:04:23 +01:00
parent cde9a6234e
commit 5fdfd903f4
3 changed files with 25 additions and 5 deletions

View file

@ -14,20 +14,34 @@
<%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %> <%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
<% for i, section in ipairs(self.children) do %> <% for i, section in ipairs(self.children) do %>
<%- if not self.selected_tab then self.selected_tab = section.sectiontype end %> <%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
<li id="tab.m-<%=self.config%>.<%=section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>"> <li id="tab.m-<%=self.config%>.<%=section.section or section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.sectiontype%>"><%=section.title or section.sectiontype %></a> <a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.section or section.sectiontype%>"><%=section.title or section.section or section.sectiontype %></a>
<% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.sectiontype%>" /><% end %> <% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.section or section.sectiontype%>" /><% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<br />
<% for i, section in ipairs(self.children) do %> <% for i, section in ipairs(self.children) do %>
<div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>> <div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.section or section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>>
<% section:render() %> <% section:render() %>
</div> </div>
<script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.sectiontype%>')</script> <script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')</script>
<% end %> <% end %>
<% if not self.save then -%>
<div class="cbi-section-error">
<% for _, section in ipairs(self.children) do %>
<% if section.error and section.error[section.section] then -%>
<ul><li>
<%:One or more invalid/required values on tab%>:&nbsp;<%=section.title or section.section or section.sectiontype%>
</li></ul>
<%- end %>
<% end %>
</div>
<%- end %>
<% else %> <% else %>
<%- self:render_children() %> <%- self:render_children() %>
<% end %> <% end %>
<br /> <br />
</div> </div>

View file

@ -1929,6 +1929,9 @@ msgstr "Es muss entweder ein Hostname oder eine MAC-Adresse angegeben werden!"
msgid "One or more fields contain invalid values!" msgid "One or more fields contain invalid values!"
msgstr "Ein oder mehrere Felder enthalten ungültige Werte!" msgstr "Ein oder mehrere Felder enthalten ungültige Werte!"
msgid "One or more invalid/required values on tab"
msgstr "Ein oder mehrere ungültige/benötigte Werte auf Registerkarte"
msgid "One or more required fields have no value!" msgid "One or more required fields have no value!"
msgstr "Ein oder mehr benötigte Felder sind nicht ausgefüllt!" msgstr "Ein oder mehr benötigte Felder sind nicht ausgefüllt!"

View file

@ -1831,6 +1831,9 @@ msgstr ""
msgid "One or more fields contain invalid values!" msgid "One or more fields contain invalid values!"
msgstr "" msgstr ""
msgid "One or more invalid/required values on tab"
msgstr ""
msgid "One or more required fields have no value!" msgid "One or more required fields have no value!"
msgstr "" msgstr ""