extracts officer_assignments from admin's poll/show
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= form_tag(search_officers_admin_poll_path(@poll), method: :get, remote: true) do |f| %>
|
||||
<%= form_tag(search_officers_admin_poll_officer_assignments_path(@poll), method: :get, remote: true) do |f| %>
|
||||
<div class="input-group">
|
||||
<%= text_field_tag :search,
|
||||
@search,
|
||||
@@ -10,8 +10,8 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.polls.show.table_name") %></th>
|
||||
<th><%= t("admin.polls.show.table_email") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.table_name") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.table_email") %></th>
|
||||
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -26,12 +26,12 @@
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<% if @poll.officer_ids.include?(user.poll_officer.id) %>
|
||||
<%= link_to t("admin.polls.show.edit_officer_assignments"),
|
||||
admin_officer_assignments_path(poll: @poll, officer: user.poll_officer),
|
||||
<%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"),
|
||||
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id),
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t("admin.polls.show.add_officer_assignments"),
|
||||
admin_officer_assignments_path(poll: @poll, officer: user.poll_officer),
|
||||
<%= link_to t("admin.poll_officer_assignments.index.add_officer_assignments"),
|
||||
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
</td>
|
||||
127
app/views/admin/poll/officer_assignments/by_officer.html.erb
Normal file
127
app/views/admin/poll/officer_assignments/by_officer.html.erb
Normal file
@@ -0,0 +1,127 @@
|
||||
<%= link_to admin_poll_officer_assignments_path(@poll) do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= @poll.name %>
|
||||
<% end %>
|
||||
|
||||
<h2><%= @officer.name %> - <%= @officer.email %></h2>
|
||||
|
||||
<%= form_tag(admin_poll_officer_assignments_path(@poll), {id: "officer_assignment_form"}) do %>
|
||||
<fieldset class="fieldset">
|
||||
<legend><%= t("admin.poll_officer_assignments.by_officer.new_assignment") %></legend>
|
||||
<div class="small-12 medium-4 column">
|
||||
<label><%= t("admin.poll_officer_assignments.by_officer.date") %></label>
|
||||
<%= select_tag :date,
|
||||
poll_dates_select_options(@poll) + poll_final_recount_option(@poll),
|
||||
{ prompt: t("admin.poll_officer_assignments.by_officer.select_date"),
|
||||
label: false } %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<label><%= t("admin.poll_officer_assignments.by_officer.booth") %></label>
|
||||
<%= select_tag :booth_id,
|
||||
poll_booths_select_options(@poll),
|
||||
{ prompt: t("admin.poll_officer_assignments.by_officer.select_booth"),
|
||||
label: false } %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= hidden_field_tag :officer_id, @officer.id %>
|
||||
<%= hidden_field_tag :poll_id, @poll.id %>
|
||||
<%= submit_tag t("admin.poll_officer_assignments.by_officer.add_assignment"),
|
||||
class: "button expanded hollow margin-top" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if @officer_assignments.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.poll_officer_assignments.by_officer.no_assignments") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<h3><%= t("admin.poll_officer_assignments.by_officer.assignments") %></h3>
|
||||
<table class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.assignment") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="<%= dom_id officer_assignment %>">
|
||||
<td><%= officer_assignment.final? ? t('polls.final_date') : l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.poll_officer_assignments.by_officer.remove_assignment"),
|
||||
admin_poll_officer_assignment_path(@poll, officer_assignment),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
|
||||
<% if voting_days_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.by_officer.recounts") %></h3>
|
||||
<table id="recount_list" class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% voting_days_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<td class="text-right">
|
||||
<% if officer_assignment.recount.present? %>
|
||||
<%= officer_assignment.recount.count %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
|
||||
<% if final_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.by_officer.final_recounts") %></h3>
|
||||
<table id="final_recount_list" class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.final_recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% final_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<td class="text-right">
|
||||
<% if officer_assignment.final_recounts.any? %>
|
||||
<%= officer_assignment.final_recounts.to_a.sum(&:count) %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
@@ -1,127 +1,40 @@
|
||||
<%= link_to admin_poll_path(@poll, anchor: 'tab-officers') do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= @poll.name %>
|
||||
<% end %>
|
||||
<%= render "/admin/poll/polls/poll_header" %>
|
||||
<div id="poll-resources">
|
||||
<%= render "/admin/poll/polls/filter_subnav" %>
|
||||
<%= render "search_officers" %>
|
||||
|
||||
<h2><%= @officer.name %> - <%= @officer.email %></h2>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.officers_title") %></h3>
|
||||
|
||||
<%= form_tag(admin_officer_assignments_path, {id: "officer_assignment_form"}) do %>
|
||||
<fieldset class="fieldset">
|
||||
<legend><%= t("admin.poll_officer_assignments.index.new_assignment") %></legend>
|
||||
<div class="small-12 medium-4 column">
|
||||
<label><%= t("admin.poll_officer_assignments.index.date") %></label>
|
||||
<%= select_tag :date,
|
||||
poll_dates_select_options(@poll) + poll_final_recount_option(@poll),
|
||||
{ prompt: t("admin.poll_officer_assignments.index.select_date"),
|
||||
label: false } %>
|
||||
<% if @officers.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.poll_officer_assignments.index.no_officers") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<label><%= t("admin.poll_officer_assignments.index.booth") %></label>
|
||||
<%= select_tag :booth_id,
|
||||
poll_booths_select_options(@poll),
|
||||
{ prompt: t("admin.poll_officer_assignments.index.select_booth"),
|
||||
label: false } %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= hidden_field_tag :officer_id, @officer.id %>
|
||||
<%= hidden_field_tag :poll_id, @poll.id %>
|
||||
<%= submit_tag t("admin.poll_officer_assignments.index.add_assignment"),
|
||||
class: "button expanded hollow margin-top" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if @officer_assignments.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.poll_officer_assignments.index.no_assignments") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.assignments") %></h3>
|
||||
<table class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.index.assignment") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="<%= dom_id officer_assignment %>">
|
||||
<td><%= officer_assignment.final? ? t('polls.final_date') : l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.poll_officer_assignments.index.remove_assignment"),
|
||||
admin_officer_assignment_path(officer_assignment),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
|
||||
<% if voting_days_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.recounts") %></h3>
|
||||
<table id="recount_list" class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.index.recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% voting_days_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<td class="text-right">
|
||||
<% if officer_assignment.recount.present? %>
|
||||
<%= officer_assignment.recount.count %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
|
||||
<% if final_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.final_recounts") %></h3>
|
||||
<table id="final_recount_list" class="fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
|
||||
<th class="text-right"><%= t("admin.poll_officer_assignments.index.final_recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% final_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<% else %>
|
||||
<table class="fixed margin">
|
||||
<thead>
|
||||
<th><%= t("admin.poll_officer_assignments.index.table_name") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.table_email") %></th>
|
||||
<th class="text-right"><%= t("admin.actions.actions") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @officers.each do |officer| %>
|
||||
<tr id="officer_<%= officer.id %>" class="officer">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to officer.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id) %>
|
||||
</strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= officer.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<% if officer_assignment.final_recounts.any? %>
|
||||
<%= officer_assignment.final_recounts.to_a.sum(&:count) %>
|
||||
<% else %>
|
||||
<span>-</span>
|
||||
<% end %>
|
||||
<%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"),
|
||||
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id),
|
||||
class: "button hollow" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -12,7 +12,7 @@
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "#tab-officers" do %>
|
||||
<%= link_to admin_poll_officer_assignments_path(@poll) do %>
|
||||
<%= t("admin.polls.show.officers_tab") %>
|
||||
(<%= @poll.officer_assignments.select(:officer_id).distinct.count %>)
|
||||
<% end %>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<h3><%= t("admin.polls.show.officers_title") %></h3>
|
||||
|
||||
<% if @poll.officers.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.polls.show.no_officers") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="fixed margin">
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.table_name") %></th>
|
||||
<th><%= t("admin.polls.show.table_email") %></th>
|
||||
<th class="text-right"><%= t("admin.actions.actions") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.officers.uniq.each do |officer| %>
|
||||
<tr id="officer_<%= officer.id %>" class="officer">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %>
|
||||
</strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= officer.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.polls.show.edit_officer_assignments"),
|
||||
admin_officer_assignments_path(officer: officer, poll: @poll),
|
||||
class: "button hollow" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
@@ -8,11 +8,6 @@
|
||||
<%= render "questions" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-officers">
|
||||
<%= render "search_officers" %>
|
||||
<%= render 'officers' %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-recounts">
|
||||
<%= render 'recounting' %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user