<%= render 'shared/back_link' %>
<div class="clear"></div>

<h2 class="inline-block">
  <%= @booth.name %>
</h2>
<%= link_to t("admin.actions.edit"),
            edit_admin_poll_booth_path(@poll, @booth),
            class: "button hollow float-right" %>

<p>
  <strong><%= t("admin.booths.show.location") %></strong>:
  <%= @booth.location %>
</p>

<h3><%= t("admin.booths.show.officers_list") %></h3>

<% if @booth.officers.empty? %>
  <div class="callout primary">
    <%= t("admin.booths.show.no_officers") %>
  </div>
<% end %>

<div class="small-12 column">
  <%= form_for @booth, url: admin_poll_booth_path(@poll, @booth) do |f| %>

    <%= f.label :officer_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
    <%= f.collection_check_boxes :officer_ids, @officers, :id, :email do |b| %>
      <% b.label { b.check_box + truncate(officer_label(b.object), length: 60) } %>
    <% end %>

    <%= f.submit t("admin.booths.show.assign_officer"), class: "button success" %>
  <% end %>
</div>

<table id="assigned_officers">
  <% @booth.officers.each do |officer| %>
    <tr id="officer_<%= officer.id %>" class="officer">
      <td>
        <%= officer.name %>
      </td>
      <td>
        <%= officer.email %>
      </td>
      <td class="text-right">
        <%= link_to t('admin.poll_officers.officer.delete'), "#", class: "button hollow alert" %>
        <%# link_to t('admin.poll_officers.officer.delete'),
                      admin_poll_officer_path(Poll.last, officer),
                      method: :delete,
                      class: "button hollow alert"
        %>
      </td>
    </tr>
  <% end %>
</table>