<%= product_wordmark :release_me, class: "small mb-3" %>

<div class="d-flex flex-row-reverse justify-content-between align-items-right mb-3">
  <%= bootstrap_form_with url: new_project_release_template_imports_path, project: @project, 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"), id: "search-button", class: "btn btn-light border rounded-pill-left") %>
  <% end%>
</div>

<%= bootstrap_form_with url: project_release_template_imports_path, project: @project do |form| %>
<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><%= t(".table_headers.selection") %></th>
        <th><%= ContractTemplate.human_attribute_name(:name) %></th>
        <th><%= t(".table_headers.release_type") %></th>
        <th><%= ContractTemplate.human_attribute_name(:project) %></th>
      </tr>
    </thead>
    <tbody id="contract-templates">
      <% if @importable_templates.any? %>
        <%= render collection: @importable_templates, partial: 'release_template_imports/release_template' %>
      <% else %>
        <tr>
          <td colspan="5" class="py-4 text-center text-muted"><%= t(".empty") %></td>
        </tr>
      <% end %>
    </tbody>
  </table>

  <div class="row align-items-center text-center mt-4 px-3">
    <%= link_to t("shared.cancel"), [@project, :contract_templates], class: "col-3 text-reset" %>
    <% if @importable_templates.any? { |it| !it.already_imported? } %>
      <div class="col-9">
        <%= form.submit t(".actions.import"), class: "btn btn-success btn-block" %>
      </div>
    <% end %>
  </div>
</div>

<div id="importable_templates_pagination" class="mt-3">
  <%= will_paginate @importable_templates %>
<div>
<% end %>
