Extract partials to show advanced stats
This commit is contained in:
83
app/views/budgets/stats/_advanced_stats.html.erb
Normal file
83
app/views/budgets/stats/_advanced_stats.html.erb
Normal file
@@ -0,0 +1,83 @@
|
||||
<div id="advanced_statistics">
|
||||
<h3 class="section-title"><%= t("stats.advanced") %></h3>
|
||||
|
||||
<div id="total_investments" class="stats-group">
|
||||
<h4><%= t("stats.budgets.total_investments") %></h4>
|
||||
|
||||
<%= number_with_info_tags(
|
||||
stats.total_budget_investments,
|
||||
t("stats.budgets.total_investments"),
|
||||
html_class: "total-investments"
|
||||
) %>
|
||||
|
||||
<%= number_with_info_tags(stats.total_unfeasible_investments,
|
||||
t("stats.budgets.total_unfeasible_investments")) %>
|
||||
<%= number_with_info_tags(stats.total_selected_investments,
|
||||
t("stats.budgets.total_selected_investments")) %>
|
||||
</div>
|
||||
|
||||
<div id="stats_by_phase" class="stats-group">
|
||||
<h4><%= t("stats.budgets.by_phase") %></h4>
|
||||
|
||||
<% stats.phases.each do |phase| %>
|
||||
<%= number_with_info_tags(
|
||||
stats.send("total_participants_#{phase}_phase"),
|
||||
t("stats.budgets.participants_#{phase}_phase")
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="stats_by_heading" class="stats-group">
|
||||
<h4 class="margin-bottom"><%= t("stats.budgets.by_heading") %></h4>
|
||||
|
||||
<table class="stats-districts survey-districts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" rowspan="2"><%= t("stats.budgets.heading") %></th>
|
||||
<th scope="col" rowspan="2"><%= t("stats.budgets.investments_sent_html") %></th>
|
||||
|
||||
<% stats.all_phases.each do |phase| %>
|
||||
<th scope="col" colspan="3">
|
||||
<%= t("stats.budgets.participants_#{phase}_phase") %>
|
||||
</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<% stats.all_phases.each do %>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.total") %></th>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.percent_total_participants") %></th>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.percent_heading_census") %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="headings">
|
||||
<% @headings.each do |heading| %>
|
||||
<tr id="<%= heading.name.parameterize %>">
|
||||
<td class="border-left">
|
||||
<strong><%= heading.name %></strong>
|
||||
</td>
|
||||
<td id="total_spending_proposals_heading_<%= heading.id %>"
|
||||
class="text-center border-left border-right">
|
||||
<%= stats.headings[heading.id][:total_investments_count] %>
|
||||
</td>
|
||||
|
||||
<% stats.all_phases.each do |phase| %>
|
||||
<td id="total_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="border-left text-center">
|
||||
<%= stats.headings[heading.id]["total_participants_#{phase}_phase".to_sym] %>
|
||||
</td>
|
||||
<td id="percentage_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="border-left border-right text-center">
|
||||
<%= number_to_stats_percentage(stats.headings[heading.id]["percentage_participants_#{phase}_phase".to_sym]) %>
|
||||
</td>
|
||||
<td id="percentage_district_population_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="text-center border-right">
|
||||
<%= number_to_stats_percentage(stats.headings[heading.id]["percentage_district_population_#{phase}_phase".to_sym]) %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
12
app/views/budgets/stats/_advanced_stats_links.html.erb
Normal file
12
app/views/budgets/stats/_advanced_stats_links.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<p><strong><%= link_to t("stats.advanced"), "#advanced_statistics" %></strong></p>
|
||||
<ul class="menu vertical">
|
||||
<li>
|
||||
<%= link_to t("stats.budgets.total_investments"), "#total_investments" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("stats.budgets.by_phase"), "#stats_by_phase" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("stats.budgets.by_heading"), "#stats_by_heading" %>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -41,107 +41,12 @@
|
||||
<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.budgets.total_investments"), "#total_investments" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("stats.budgets.by_phase"), "#stats_by_phase" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t("stats.budgets.by_heading"), "#stats_by_heading" %>
|
||||
</li>
|
||||
</ul>
|
||||
<%= render "advanced_stats_links" %>
|
||||
</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="total_investments" class="stats-group">
|
||||
<h4><%= t("stats.budgets.total_investments") %></h4>
|
||||
|
||||
<%= number_with_info_tags(
|
||||
@stats.total_budget_investments,
|
||||
t("stats.budgets.total_investments"),
|
||||
html_class: "total-investments"
|
||||
) %>
|
||||
|
||||
<%= number_with_info_tags(@stats.total_unfeasible_investments,
|
||||
t("stats.budgets.total_unfeasible_investments")) %>
|
||||
<%= number_with_info_tags(@stats.total_selected_investments,
|
||||
t("stats.budgets.total_selected_investments")) %>
|
||||
</div>
|
||||
|
||||
<div id="stats_by_phase" class="stats-group">
|
||||
<h4><%= t("stats.budgets.by_phase") %></h4>
|
||||
|
||||
<% @stats.phases.each do |phase| %>
|
||||
<%= number_with_info_tags(
|
||||
@stats.send("total_participants_#{phase}_phase"),
|
||||
t("stats.budgets.participants_#{phase}_phase")
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="stats_by_heading" class="stats-group">
|
||||
<h4 class="margin-bottom"><%= t("stats.budgets.by_heading") %></h4>
|
||||
|
||||
<table class="stats-districts survey-districts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" rowspan="2"><%= t("stats.budgets.heading") %></th>
|
||||
<th scope="col" rowspan="2"><%= t("stats.budgets.investments_sent_html") %></th>
|
||||
|
||||
<% @stats.all_phases.each do |phase| %>
|
||||
<th scope="col" colspan="3">
|
||||
<%= t("stats.budgets.participants_#{phase}_phase") %>
|
||||
</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<% @stats.all_phases.each do %>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.total") %></th>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.percent_total_participants") %></th>
|
||||
<th scope="col" class="phase-subheader"><%= t("stats.budgets.percent_heading_census") %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="headings">
|
||||
<% @headings.each do |heading| %>
|
||||
<tr id="<%= heading.name.parameterize %>">
|
||||
<td class="border-left">
|
||||
<strong><%= heading.name %></strong>
|
||||
</td>
|
||||
<td id="total_spending_proposals_heading_<%= heading.id %>"
|
||||
class="text-center border-left border-right">
|
||||
<%= @stats.headings[heading.id][:total_investments_count] %>
|
||||
</td>
|
||||
|
||||
<% @stats.all_phases.each do |phase| %>
|
||||
<td id="total_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="border-left text-center">
|
||||
<%= @stats.headings[heading.id]["total_participants_#{phase}_phase".to_sym] %>
|
||||
</td>
|
||||
<td id="percentage_participants_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="border-left border-right text-center">
|
||||
<%= number_to_stats_percentage(@stats.headings[heading.id]["percentage_participants_#{phase}_phase".to_sym]) %>
|
||||
</td>
|
||||
<td id="percentage_district_population_<%= phase %>_phase_heading_<%= heading.id %>"
|
||||
class="text-center border-right">
|
||||
<%= number_to_stats_percentage(@stats.headings[heading.id]["percentage_district_population_#{phase}_phase".to_sym]) %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<%= render "advanced_stats", stats: @stats %>
|
||||
|
||||
<div class="row margin">
|
||||
<div class="small-12 column">
|
||||
|
||||
92
app/views/polls/_advanced_stats.html.erb
Normal file
92
app/views/polls/_advanced_stats.html.erb
Normal file
@@ -0,0 +1,92 @@
|
||||
<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>
|
||||
9
app/views/polls/_advanced_stats_links.html.erb
Normal file
9
app/views/polls/_advanced_stats_links.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<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>
|
||||
@@ -8,118 +8,17 @@
|
||||
<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>
|
||||
<%= render "advanced_stats_links" %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column stats-content">
|
||||
<%= render "shared/stats/participation", stats: @stats %>
|
||||
<%= render "advanced_stats", 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 id="total_no_demographic_data">
|
||||
<p class="help-text">
|
||||
<%= t("stats.no_demographic_data", count: @stats.total_no_demographic_data) %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user