From 573e04ef8f3a7d00fc1a02c400135db14172b700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 4 Jan 2019 19:17:33 +0100 Subject: [PATCH] Move common stats to partials --- app/views/polls/stats.html.erb | 76 +------------------ app/views/shared/stats/_links.html.erb | 12 +++ .../shared/stats/_participation.html.erb | 62 +++++++++++++++ 3 files changed, 76 insertions(+), 74 deletions(-) create mode 100644 app/views/shared/stats/_links.html.erb create mode 100644 app/views/shared/stats/_participation.html.erb 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])})" %> + +
+ + +
+
+
+