extracts booth_assignment from admin's poll/show

This commit is contained in:
Juanjo Bazán
2017-02-14 13:00:19 +01:00
parent 22d9c17ab4
commit 20e31133a8
16 changed files with 156 additions and 133 deletions

View File

@@ -1,35 +0,0 @@
<h3><%= t("admin.polls.show.booths_title") %></h3>
<% if @poll.booth_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.polls.show.no_booths") %>
</div>
<% else %>
<table id="assigned_booths_list" class="fixed margin">
<thead>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_location") %></th>
<th class="text-right"><%= t("admin.polls.show.table_assignment") %></th>
</thead>
<tbody>
<% @poll.booth_assignments.each do |booth_assignment| %>
<tr id="<%= dom_id(booth_assignment) %>" class="booth">
<td>
<strong>
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment) %>
</strong>
</td>
<td>
<%= booth_assignment.booth.location %>
</td>
<td class="text-right">
<%= link_to t("admin.polls.show.remove_booth"),
admin_booth_assignment_path(booth_assignment),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -1,28 +1,28 @@
<ul class="tabs" data-tabs id="assigned-resources-tabs">
<li class="tabs-title is-active">
<%= link_to "#tab-questions" do %>
<ul class="menu simple clear" id="assigned-resources-tabs">
<li>
<%= link_to admin_poll_path(@poll) do %>
<%= t("admin.polls.show.questions_tab") %>
<span class="js-comments-count">(<%= @poll.questions.count %>)</span>
(<%= @poll.questions.count %>)
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-booths" do %>
<li>
<%= link_to admin_poll_booth_assignments_path(@poll) do %>
<%= t("admin.polls.show.booths_tab") %>
(<%= @poll.booths.count %>)
(<%= @poll.booth_assignments.select(:booth_id).distinct.count %>)
<% end %>
</li>
<li class="tabs-title">
<li>
<%= link_to "#tab-officers" do %>
<%= t("admin.polls.show.officers_tab") %>
(<%= @poll.officers.uniq.count %>)
(<%= @poll.officer_assignments.select(:officer_id).distinct.count %>)
<% end %>
</li>
<li class="tabs-title">
<li>
<%= link_to "#tab-recounts" do %>
<%= t("admin.polls.show.recounts_tab") %>
<% end %>
</li>
<li class="tabs-title">
<li>
<%= link_to "#tab-results" do %>
<%= t("admin.polls.show.results_tab") %>
<% end %>

View File

@@ -0,0 +1,17 @@
<%= link_to t("admin.actions.edit"),
edit_admin_poll_path(@poll),
class: "button hollow float-right" %>
<h2 class="inline-block">
<%= @poll.name %>
</h2>
<br>
<span>
(<%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %>)
</span>
<% if @poll.geozone_restricted %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span>
<%= @poll.geozones.pluck(:name).to_sentence %>
<span>
<% end %>

View File

@@ -1,16 +0,0 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= form_tag(search_booths_admin_poll_path(@poll), method: :get, remote: true) do |f| %>
<div class="input-group">
<%= text_field_tag :search,
@search,
placeholder: t("admin.shared.booths_search.placeholder"), id: "search-booths" %>
<div class="input-group-button">
<%= submit_tag t("admin.shared.booths_search.button"), class: "button" %>
</div>
</div>
<% end %>
</div>
</div>
<div id="search-booths-results"></div>

View File

@@ -1,44 +0,0 @@
<% if @booths.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<% end %>
<% if @booths.any? %>
<table>
<thead>
<tr>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_location") %></th>
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
</tr>
</thead>
<tbody>
<% @booths.each do |booth| %>
<tr>
<td>
<%= booth.name %>
</td>
<td>
<%= booth.location %>
</td>
<td class="text-center">
<% if @poll.booth_ids.include?(booth.id) %>
<%= link_to t("admin.polls.show.remove_booth"),
admin_booth_assignment_path(poll: @poll, booth: booth),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t("admin.polls.show.add_booth"),
admin_booth_assignments_path(poll: @poll, booth: booth),
method: :post,
class: "button hollow" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -1,9 +1,9 @@
<% if @officers.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
<%= t('admin.shared.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<h3><%= t('admin.shared.search_results') %></h3>
<% end %>
<% if @officers.any? %>

View File

@@ -1,9 +1,9 @@
<% if @questions.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
<%= t('admin.shared.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<h3><%= t('admin.shared.search_results') %></h3>
<% end %>
<% if @questions.any? %>

View File

@@ -1 +0,0 @@
$("#search-booths-results").html("<%= j render 'search_booths_results' %>");

View File

@@ -1,34 +1,13 @@
<%= link_to t("admin.actions.edit"),
edit_admin_poll_path(@poll),
class: "button hollow float-right" %>
<%= render "poll_header" %>
<h2 class="inline-block">
<%= @poll.name %>
</h2>
<br>
<span>
(<%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %>)
</span>
<% if @poll.geozone_restricted %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span>
<%= @poll.geozones.pluck(:name).to_sentence %>
<span>
<% end %>
<div id="poll-resources" class="tabs-content" data-tabs-content="assigned-resources-tabs">
<div id="poll-resources">
<%= render "filter_subnav" %>
<div class="tabs-panel is-active" id="tab-questions">
<div class="tabs-panel" id="tab-questions">
<%= render "search_questions" %>
<%= render "questions" %>
</div>
<div class="tabs-panel" id="tab-booths">
<%= render "search_booths" %>
<%= render "booths" %>
</div>
<div class="tabs-panel" id="tab-officers">
<%= render "search_officers" %>
<%= render 'officers' %>