diff --git a/app/views/polls/stats.html.erb b/app/views/polls/stats.html.erb index 54ad19a59..e09780af0 100644 --- a/app/views/polls/stats.html.erb +++ b/app/views/polls/stats.html.erb @@ -11,85 +11,13 @@
-

<%= link_to t("stats.title"), "#participation_statistics" %>

- + <%= render "shared/stats/links" %>
-
-

<%= t("stats.title") %>

- -
-

<%= t("stats.total_participants") %>

- -

- <%= @stats[:total_participants] %> - <%= t("polls.show.stats.total_votes") %> -

-
- -
-

<%= t("stats.by_gender") %>

- -

- <%= @stats[:total_male_participants] %> - - <%= I18n.t("stats.men_percentage", - percentage: number_to_stats_percentage(@stats[:male_percentage])) %> - -

- -

- <%= @stats[:total_female_participants] %> - - <%= I18n.t("stats.women_percentage", - percentage: number_to_stats_percentage(@stats[:female_percentage])) %> - -

-
- -
-

<%= t("stats.by_age") %>

- - - - - - - - - - - <% @stats[:age_groups].values.each do |group| %> - - - - - <% end %> - -
<%= t("stats.age") %><%= t("stats.total") %>
<%= group[:range] %> - - <%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %> - -
- - -
-
-
-
+ <%= render "shared/stats/participation", stats: @stats %> diff --git a/app/views/shared/stats/_links.html.erb b/app/views/shared/stats/_links.html.erb new file mode 100644 index 000000000..7b7d6d7ac --- /dev/null +++ b/app/views/shared/stats/_links.html.erb @@ -0,0 +1,12 @@ +

<%= link_to t("stats.title"), "#participation_statistics" %>

+ diff --git a/app/views/shared/stats/_participation.html.erb b/app/views/shared/stats/_participation.html.erb new file mode 100644 index 000000000..cf31920db --- /dev/null +++ b/app/views/shared/stats/_participation.html.erb @@ -0,0 +1,62 @@ +
+

<%= t("stats.title") %>

+ +
+

<%= t("stats.total_participants") %>

+ +

+ <%= stats[:total_participants] %> + <%= t("polls.show.stats.total_votes") %> +

+
+ +
+

<%= t("stats.by_gender") %>

+ +

+ <%= stats[:total_male_participants] %> + + <%= I18n.t("stats.men_percentage", + percentage: number_to_stats_percentage(stats[:male_percentage])) %> + +

+ +

+ <%= stats[:total_female_participants] %> + + <%= I18n.t("stats.women_percentage", + percentage: number_to_stats_percentage(stats[:female_percentage])) %> + +

+
+ +
+

<%= t("stats.by_age") %>

+ +
+ + + + + + + + + <% stats[:age_groups].values.each do |group| %> + + + + + <% end %> + +
<%= t("stats.age") %><%= t("stats.total") %>
<%= group[:range] %> + + <%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %> + +
+ + +
+
+
+