Files
nairobi/app/views/polls/stats.html.erb
Javi Martín e146fafb60 Only show "no demographic data" when necessary
If there's demographic data for all participants, it doesn't make sense
to show the message.

We're using translations instead of an `if` in the view because the text
is also different when there's only one participant. In some languages
the text might also be different depending on how many people with no
demographic data participated.

Another possibility would be to use an `if` in the view so we don't
display an empty paragraph when the cont is zero, and then using
translation for `one` and `other`. I haven't gone that way because I
thought the logic would be more complex and the benefits wouldn't be
that great.
2019-05-21 13:50:18 +02:00

128 lines
4.4 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", stats: @stats %>
<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.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>
<% @stats.channels.each do |channel| %>
<%= number_with_info_tags(
@stats.send("total_participants_#{channel}"),
t("stats.polls.#{channel}_percentage",
percentage: number_to_stats_percentage(@stats.send(:"total_participants_#{channel}_percentage"))
),
html_class: channel
) %>
<% end %>
</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>
<% @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>
<% @stats.channels.each do |channel| %>
<td>
<%= @stats.send(:"total_#{channel}_valid") %>
<small><em>(<%= @stats.send(:"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>
<% @stats.channels.each do |channel| %>
<td>
<%= @stats.send(:"total_#{channel}_white") %>
<small><em>(<%= @stats.send(:"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>
<% @stats.channels.each do |channel| %>
<td>
<%= @stats.send(:"total_#{channel}_null") %>
<small><em>(<%= @stats.send(:"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>
<% @stats.channels.each do |channel| %>
<td>
<%= @stats.send(:"total_participants_#{channel}") %>
<small><em>(<%= @stats.send(:"total_participants_#{channel}_percentage").round(2) %>%)</em></small>
</td>
<% end %>
<td><%= @stats.total_participants %></td>
</tr>
</tbody>
</table>
</div>
<div id="total_no_demographic_data">
<p class="help-text">
<%= t("stats.no_demographic_data", count: @stats.total_no_demographic_data) %>
</p>
</div>
</div>
</div>
</div>
</div>