Move common stats to partials

This commit is contained in:
Javi Martín
2019-01-04 19:17:33 +01:00
parent 88daaee9fe
commit 573e04ef8f
3 changed files with 76 additions and 74 deletions

View File

@@ -11,85 +11,13 @@
<div class="sticky" data-sticky
data-sticky-on="large"
data-anchor="participation_statistics">
<p><strong><%= link_to t("stats.title"), "#participation_statistics" %></strong></p>
<ul class="menu vertical">
<li>
<%= link_to t("stats.total_participants"), "#total_participants" %>
</li>
<li>
<%= link_to t("stats.by_gender"), "#participants_by_gender" %>
</li>
<li>
<%= link_to t("stats.by_age"), "#participants_by_age" %>
</li>
</ul>
<%= render "shared/stats/links" %>
</div>
</div>
</div>
<div class="small-12 medium-9 column" data-equalizer-watch>
<div id="participation_statistics">
<h3 class="section-title"><%= t("stats.title") %></h3>
<div id="total_participants" class="stats-group" >
<h4><%= t("stats.total_participants") %></h4>
<p class="participants">
<span class="number"><%= @stats[:total_participants] %></span>
<span class="info"><%= t("polls.show.stats.total_votes") %></span>
</p>
</div>
<div id="participants_by_gender" class="stats-group">
<h4><%= t("stats.by_gender") %></h4>
<p class="gender male participants">
<span class="number"><%= @stats[:total_male_participants] %></span>
<span class="info">
<%= I18n.t("stats.men_percentage",
percentage: number_to_stats_percentage(@stats[:male_percentage])) %>
</span>
</p>
<p class="gender female participants">
<span class="number"><%= @stats[:total_female_participants] %></span>
<span class="info">
<%= I18n.t("stats.women_percentage",
percentage: number_to_stats_percentage(@stats[:female_percentage])) %>
</span>
</p>
</div>
<div id="participants_by_age" class="stats-group">
<h4><%= t("stats.by_age") %></h4>
<table>
<thead>
<tr>
<th class="small-4"><%= t("stats.age") %></th>
<th><%= t("stats.total") %></th>
</tr>
</thead>
<tbody>
<% @stats[:age_groups].values.each do |group| %>
<tr>
<td><%= group[:range] %></td>
<td>
<strong>
<%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %>
</strong>
<div class="progress" tabindex="0">
<span class="progress-meter" style="width: <%= group[:percentage] %>%">
</span>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= render "shared/stats/participation", stats: @stats %>
<table>
<thead>

View File

@@ -0,0 +1,12 @@
<p><strong><%= link_to t("stats.title"), "#participation_statistics" %></strong></p>
<ul class="menu vertical">
<li>
<%= link_to t("stats.total_participants"), "#total_participants" %>
</li>
<li>
<%= link_to t("stats.by_gender"), "#participants_by_gender" %>
</li>
<li>
<%= link_to t("stats.by_age"), "#participants_by_age" %>
</li>
</ul>

View File

@@ -0,0 +1,62 @@
<div id="participation_statistics">
<h3 class="section-title"><%= t("stats.title") %></h3>
<div id="total_participants" class="stats-group">
<h4><%= t("stats.total_participants") %></h4>
<p class="participants">
<span class="number"><%= stats[:total_participants] %></span>
<span class="info"><%= t("polls.show.stats.total_votes") %></span>
</p>
</div>
<div id="participants_by_gender" class="stats-group">
<h4><%= t("stats.by_gender") %></h4>
<p class="gender male participants">
<span class="number"><%= stats[:total_male_participants] %></span>
<span class="info">
<%= I18n.t("stats.men_percentage",
percentage: number_to_stats_percentage(stats[:male_percentage])) %>
</span>
</p>
<p class="gender female participants">
<span class="number"><%= stats[:total_female_participants] %></span>
<span class="info">
<%= I18n.t("stats.women_percentage",
percentage: number_to_stats_percentage(stats[:female_percentage])) %>
</span>
</p>
</div>
<div id="participants_by_age" class="stats-group">
<h4><%= t("stats.by_age") %></h4>
<table>
<thead>
<tr>
<th class="small-4"><%= t("stats.age") %></th>
<th><%= t("stats.total") %></th>
</tr>
</thead>
<tbody>
<% stats[:age_groups].values.each do |group| %>
<tr>
<td><%= group[:range] %></td>
<td>
<strong>
<%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %>
</strong>
<div class="progress" tabindex="0">
<span class="progress-meter" style="width: <%= group[:percentage] %>%">
</span>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>