Skip to content
Snippets Groups Projects
Commit 7c281fc6 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

groups

parent ff42fa1a
No related branches found
No related tags found
No related merge requests found
......@@ -26,12 +26,32 @@ module WithAccessibility
@accessibility_errors
end
def accessibility_errors_grouped
@accessibility_errors_grouped ||= accessibility_create_groups(accessibility_errors)
end
def accessibility_warnings
check_accessibility_if_necessary
@accessibility_warnings
end
def accessibility_warnings_grouped
@accessibility_warnings_grouped ||= accessibility_create_groups(accessibility_warnings)
end
protected
def accessibility_create_groups(identifiers)
hash = {}
identifiers.each do |identifier|
if hash.has_key?(identifier)
hash[identifier] += 1
else
hash[identifier] = 1
end
end
hash
end
def check_accessibility_if_necessary
unless @accessibility_checked
......
......@@ -7,15 +7,19 @@ action = "<i class=\"#{ Icon::A11Y } #{ if_appstack 'fa-2x' } h4 float-end #{ co
<% if horizontal %>
<div class="row"><div class="offset-lg-4 col-lg-8 mt-lg-n4">
<% end %>
<% if about.accessibility_errors.any? %>
<% if about.accessibility_errors_grouped.any? %>
<p class="text-danger">
<i class="<%= Icon::A11Y %>"></i>
<%= t('accessibility.errors', count: about.accessibility_errors.count) %>
</p>
<ol class="list-unstyled">
<% about.accessibility_errors.each do |key| %>
<% about.accessibility_errors_grouped.each do |key, quantity| %>
<li>
<%= osuny_label t("#{key}.title"), classes: 'text-danger' %>
<%
label = t("#{key}.title")
label += " (× #{quantity})" if quantity > 1
%>
<%= osuny_label label, classes: 'text-danger' %>
<p><%= t "#{key}.text_html" %></p>
</li>
<% end %>
......@@ -26,12 +30,16 @@ action = "<i class=\"#{ Icon::A11Y } #{ if_appstack 'fa-2x' } h4 float-end #{ co
<%= t 'accessibility.errors', count: 0 %>
</p>
<% end %>
<% if about.accessibility_warnings.any? %>
<% if about.accessibility_warnings_grouped.keys.any? %>
<%= osuny_label t('accessibility.warnings', count: about.accessibility_warnings.count) %>
<ul class="list-unstyled">
<% about.accessibility_warnings.each do |key| %>
<% about.accessibility_warnings_grouped.each do |key, quantity| %>
<li>
<%= osuny_label t("#{key}.title") %>
<%
label = t("#{key}.title")
label += " (× #{quantity})" if quantity > 1
%>
<%= osuny_label label %>
<p>
<%= t "#{key}.text_html" %>
</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment