<div class="row">
  <div class="col-md-12">
    <div id="upload-progress-container" class="mb-1"></div>
    <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-2">
      <% if policy(AppearanceRelease).new? %>
        <div class="mr-auto">
          <%= bootstrap_form_with url: project_appearance_release_imports_path, method: :post, id: "appearance_releases_import", remote: true, layout: :inline do |form| %>
            <%= form.file_field :attachments, disable: true, direct_upload: true, multiple: true, accept: AppearanceRelease.acceptable_import_file_extensions.join(','), id: "appearance_release_file_upload", hide_label: true, hidden: true %>
            <%= form.button fa_icon('plus', text: t('.actions.new')), class: 'btn btn-primary mr-2 mb-2', type: :button, id: 'import_appearance_releases' %>
          <% end %>
        </div>
      <% end %>

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

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

<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-2">
      <div id="type_filter_actions">
        <%= render 'type_filter_actions' %>
      </div>

      <div class="ml-auto">
        <%= bootstrap_form_with url: [@project, :appearance_releases], method: :get, remote: true, layout: :inline, id: "search" do |form| %>
          <%= form.hidden_field :type_filter, value: params[:type_filter] || 'all', id: 'type_filter_value' %>
          <%= 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>

<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 "appearance_release_ids[]", false, false %></th>
        <th></th>
        <th><%= AppearanceRelease.human_attribute_name(:person_name) %></th>
        <th><%= AppearanceRelease.human_attribute_name(:contact_info) %></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="appearance_releases">
      <% if @appearance_releases.any? %>
        <%= render @appearance_releases %>
      <% else %>
        <tr>
          <td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
</div>

<div id="appearance_releases_pagination" class="mt-3">
  <%= will_paginate @appearance_releases %>
</div>
