<div class="row">
  <div class="col-md-12">
    <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
      <% if policy(TalentRelease).new? %>
        <%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :talent_release], class: "btn btn-primary mr-2 mb-2" %>
      <% end %>

      <% if @talent_releases.any? && policy(TalentRelease).tag_multiple? %>
        <%= button_to_bulk_tagging(@project) %>
      <% end %>

      <% if @talent_releases.any? && policy(TalentRelease).download_multiple? %>
        <%= link_to "Download All", [@project, :contract_downloads, release_type: @talent_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: {
            disable_with: "Please wait..." } %>
      <% end %>

      <%= bootstrap_form_with url: [@project, :talent_releases], method: :get, remote: true, layout: :inline, id: "search" do |form| %>
        <%= form.search_field :query, hide_label: true, placeholder: t(".actions.search"), class: "rounded-pill-right", value: params[:query], prepend: form.button(fa_icon("search"), class: "btn btn-light border mb-2 rounded-pill-left") %>
      <% end %>
    </div>
  </div>
</div>

<div class="border bg-white rounded shadow-sm pb-3 table-responsive">
  <table class="table table-striped tr-px-4 align-all-middle">
    <thead class="thead-light">
      <tr>
        <th data-behavior="all-selectable"><%= check_box_tag "talent_release_ids[]", false, false %></th>
        <th></th>
        <th><%= TalentRelease.human_attribute_name(:person_name) %></th>
        <th><%= TalentRelease.human_attribute_name(:person_phone) %></th>
        <th><%= TalentRelease.human_attribute_name(:person_email) %></th>
        <th><%= t(".table_headers.notes") %></th>
        <th><%= t(".table_headers.tags") %></th>
         <th><%= t(".table_headers.signed_at") %></th>

        <th></th>
      </tr>
    </thead>
    <tbody id="talent_releases">
      <% if @talent_releases.any? %>
        <%= render @talent_releases %>
      <% else %>
        <tr>
          <td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
</div>

<div id="talent_releases_pagination" class="mt-3">
  <%= will_paginate @talent_releases %>
</div>
