Files
grecia/app/views/polls/stats.html.erb
decabeza 6410d4c3e5 Replace data equalizer with css
Data equalizer was used to show a border to separate sidebar from the content. Now is the same with only css avoiding use js.
2019-05-21 13:50:17 +02:00

225 lines
8.1 KiB
Plaintext

<% provide :title do %><%= @poll.name %><% end %>
<div class="participation-stats polls-results-stats">
<%= render "poll_header" %>
<%= render "poll_subnav" %>
<div class="row margin">
<div class="small-12 medium-3 column sidebar">
<%= render "shared/stats/links" %>
<p><strong><%= link_to t("stats.advanced"), "#advanced_statistics" %></strong></p>
<ul class="menu vertical">
<li>
<%= link_to t("stats.polls.by_channel"), "#stats_by_channel" %>
</li>
<li>
<%= link_to t("stats.polls.by_gender_and_channel"), "#stats_by_gender_and_channel" %>
</li>
<li>
<%= link_to t("stats.polls.by_age_and_channel"), "#stats_by_age_and_channel" %>
</li>
<li>
<%= link_to t("stats.polls.by_geozone_and_channel"), "#stats_by_geozone_and_channel "%>
</li>
<li>
<%= link_to t("stats.polls.vote_by_channel"), "#vote_stats_by_channel" %>
</li>
</ul>
</div>
<div class="small-12 medium-9 column stats-content">
<%= render "shared/stats/participation", stats: @stats %>
<div id="advanced_statistics">
<h3 class="section-title"><%= t("stats.advanced") %></h3>
<div id="stats_by_channel" class="stats-group">
<h4><%= t("stats.polls.by_channel") %></h4>
<% Poll::Stats::CHANNELS.each do |channel| %>
<%= number_with_info_tags(
@stats[:"total_participants_#{channel}"],
t("stats.polls.#{channel}_percentage",
percentage: number_to_stats_percentage(@stats[:"total_participants_#{channel}_percentage"])
),
html_class: channel
) %>
<% end %>
</div>
<div id="stats_by_gender_and_channel" class="stats-group">
<h4><%= t("stats.polls.by_gender_and_channel") %></h4>
<table class="gender-and-channel">
<thead>
<tr>
<th class="gender"></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th class="<%= channel %>"><%= t("stats.polls.#{channel}") %></th>
<% end %>
</tr>
</thead>
<tbody>
<% %i[male female].each do |gender| %>
<tr>
<td class="<%= gender %> gender"><%= t("stats.#{gender}") %></td>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= "#{@stats[:"total_#{gender}_#{channel}"]}
(#{number_to_stats_percentage(@stats[:"#{gender}_#{channel}_percentage"])})" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="stats_by_age_and_channel" class="stats-group">
<h4><%= t("stats.polls.by_age_and_channel") %></h4>
<table>
<thead>
<tr>
<th><%= t("stats.age") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th><%= t("stats.polls.#{channel}") %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @stats[:participants_by_age].keys.each do |age_range| %>
<tr>
<td><%= @stats[:participants_by_age][age_range][:range] %></td>
<% Poll::Stats::CHANNELS.each do |channel| %>
<% group = @stats[:"#{channel}_participants_by_age"][age_range] %>
<td>
<div class="progress" tabindex="0">
<span class="progress-meter" style="width: <%= group[:percentage] %>%">
</span>
</div>
<%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="stats_by_geozone_and_channel" class="stats-group">
<h4><%= t("stats.polls.by_geozone_and_channel") %></h4>
<table>
<thead>
<tr>
<th><%= t("stats.geozone") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th><%= t("stats.polls.#{channel}") %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @stats[:web_participants_by_geozone].keys.each do |name| %>
<tr>
<td><%= name %></td>
<% Poll::Stats::CHANNELS.each do |channel| %>
<% group = @stats[:"#{channel}_participants_by_geozone"][name] %>
<td>
<div class="progress" tabindex="0">
<span class="progress-meter" style="width: <%= group[:percentage] %>%">
</span>
</div>
<%= "#{group[:count]} (#{number_to_stats_percentage(group[:percentage])})" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="vote_stats_by_channel" class="stats-group">
<h4><%= t("stats.polls.vote_by_channel") %></h4>
<table class="stack">
<thead>
<tr>
<th scope="col"><%= t("polls.show.stats.votes") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<th scope="col"><%= t("polls.show.stats.#{channel}") %></th>
<% end %>
<th scope="col"><%= t("polls.show.stats.total") %></th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><%= t("polls.show.stats.valid") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_valid"] %>
<small><em>(<%= @stats[:"valid_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<td>
<%= @stats[:total_valid_votes] %>
<small><em>(<%= @stats[:total_valid_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.white") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_white"] %>
<small><em>(<%= @stats[:"white_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<td><%= @stats[:total_white_votes] %>
<small><em>(<%= @stats[:total_white_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.null_votes") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_#{channel}_null"] %>
<small><em>(<%= @stats[:"null_percentage_#{channel}"].round(2) %>%)</em></small>
</td>
<% end %>
<td>
<%= @stats[:total_null_votes] %>
<small><em>(<%= @stats[:total_null_percentage].round(2) %>%)</em></small>
</td>
</tr>
<tr>
<th scope="row"><%= t("polls.show.stats.total") %></th>
<% Poll::Stats::CHANNELS.each do |channel| %>
<td>
<%= @stats[:"total_participants_#{channel}"] %>
<small><em>(<%= @stats[:"total_participants_#{channel}_percentage"].round(2) %>%)</em></small>
</td>
<% end %>
<td><%= @stats[:total_participants] %></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>