extracts recounting from admin's poll/show
This commit is contained in:
@@ -8,9 +8,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
@poll = Poll.includes(:questions,
|
||||
booth_assignments: [:final_recounts,
|
||||
:recounts]).
|
||||
@poll = Poll.includes(:questions).
|
||||
order('poll_questions.title').
|
||||
find(params[:id])
|
||||
end
|
||||
@@ -46,7 +44,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
||||
else
|
||||
notice = t("admin.polls.flash.error_on_question_added")
|
||||
end
|
||||
redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice
|
||||
redirect_to admin_poll_path(@poll), notice: notice
|
||||
end
|
||||
|
||||
def remove_question
|
||||
@@ -58,7 +56,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
||||
else
|
||||
notice = t("admin.polls.flash.error_on_question_removed")
|
||||
end
|
||||
redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice
|
||||
redirect_to admin_poll_path(@poll), notice: notice
|
||||
end
|
||||
|
||||
def search_questions
|
||||
|
||||
13
app/controllers/admin/poll/recounts_controller.rb
Normal file
13
app/controllers/admin/poll/recounts_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Admin::Poll::RecountsController < Admin::BaseController
|
||||
before_action :load_poll
|
||||
|
||||
def index
|
||||
@booth_assignments = @poll.booth_assignments.includes(:recounts, :final_recounts)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_poll
|
||||
@poll = ::Poll.find(params[:poll_id])
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@
|
||||
<tbody>
|
||||
<% @booth_assignment.officers.uniq.each do |officer| %>
|
||||
<tr id="officer_<%= officer.id %>" class="officer">
|
||||
<td><%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %></td>
|
||||
<td><%= link_to officer.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id) %></td>
|
||||
<td><%= officer.email %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "#tab-recounts" do %>
|
||||
<%= link_to admin_poll_recounts_path(@poll) do %>
|
||||
<%= t("admin.polls.show.recounts_tab") %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<h3><%= t("admin.polls.show.recounting_title") %></h3>
|
||||
|
||||
<% if @poll.booth_assignments.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.polls.show.no_recounts") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="fixed margin">
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.table_booth_name") %></th>
|
||||
<th class="text-center"><%= t("admin.polls.show.table_recounts") %></th>
|
||||
<th class="text-center"><%= t("admin.polls.show.table_final_recount") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.booth_assignments.each do |booth_assignment| %>
|
||||
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if booth_assignment.recounts.any? %>
|
||||
<%= booth_assignment.recounts.to_a.sum(&:count) %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if booth_assignment.final_recounts.any? %>
|
||||
<strong><%= booth_assignment.final_recounts.to_a.sum(&:count) %></strong>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
@@ -3,14 +3,8 @@
|
||||
<div id="poll-resources">
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<div class="tabs-panel" id="tab-questions">
|
||||
<%= render "search_questions" %>
|
||||
<%= render "questions" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-recounts">
|
||||
<%= render 'recounting' %>
|
||||
</div>
|
||||
<%= render "search_questions" %>
|
||||
<%= render "questions" %>
|
||||
|
||||
<div class="tabs-panel" id="tab-results">
|
||||
<%= render 'results' %>
|
||||
|
||||
45
app/views/admin/poll/recounts/index.html.erb
Normal file
45
app/views/admin/poll/recounts/index.html.erb
Normal file
@@ -0,0 +1,45 @@
|
||||
<%= render "/admin/poll/polls/poll_header" %>
|
||||
<div id="poll-resources">
|
||||
<%= render "/admin/poll/polls/filter_subnav" %>
|
||||
|
||||
<h3><%= t("admin.recounts.index.title") %></h3>
|
||||
|
||||
<% if @booth_assignments.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.recounts.index.no_recounts") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="fixed margin">
|
||||
<thead>
|
||||
<th><%= t("admin.recounts.index.table_booth_name") %></th>
|
||||
<th class="text-center"><%= t("admin.recounts.index.table_recounts") %></th>
|
||||
<th class="text-center"><%= t("admin.recounts.index.table_final_recount") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @booth_assignments.each do |booth_assignment| %>
|
||||
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if booth_assignment.recounts.any? %>
|
||||
<%= booth_assignment.recounts.to_a.sum(&:count) %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if booth_assignment.final_recounts.any? %>
|
||||
<strong><%= booth_assignment.final_recounts.to_a.sum(&:count) %></strong>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user