{% load i18n %}
<c-components.fab>
  <c-components.fab_menu_button
            color="primary"
            hx_target="#generic-offcanvas"
            url="{% url 'import_profiles_add' %}"
            icon="fa-solid fa-plus"
            title="{% trans 'New' %}"></c-components.fab_menu_button>

  <c-components.fab_menu_button
            color="primary"
            hx_target="#persistent-generic-offcanvas-left"
            url="{% url 'import_presets_list' %}"
            icon="fa-solid fa-file-code"
            title="{% trans 'From preset' %}"></c-components.fab_menu_button>
</c-components.fab>

<div class="container">
  <div class="text-3xl font-bold font-mono w-full mb-3">
    {% spaceless %}
    <div>{% translate 'Import Profiles' %}</div>
    {% endspaceless %}
  </div>

  <div class="card bg-base-100 shadow-xl">
    <div class="card-body overflow-x-auto">
      {% if profiles %}
      <c-config.search></c-config.search>
      <div class="overflow-x-auto">
        <table class="table table-zebra">
          <thead>
          <tr>
            <th scope="col" class="table-col-auto"></th>
            <th scope="col">{% translate 'Name' %}</th>
            <th scope="col">{% translate 'Version' %}</th>
          </tr>
          </thead>
          <tbody>
          {% for profile in profiles %}
            <tr class="profile">
              <td class="table-col-auto">
                <div class="join" role="group" aria-label="{% translate 'Actions' %}">
                  <a class="btn btn-secondary btn-sm join-item"
                     role="button"
                     data-tippy-content="{% translate "Edit" %}"
                     hx-get="{% url 'import_profile_edit' profile_id=profile.id %}"
                     hx-target="#generic-offcanvas">
                    <i class="fa-solid fa-pencil fa-fw"></i></a>
                  <a class="btn btn-secondary btn-sm join-item"
                     role="button"
                     data-tippy-content="{% translate "Runs" %}"
                     hx-get="{% url 'import_profile_runs_list' profile_id=profile.id %}"
                     hx-target="#persistent-generic-offcanvas-left">
                    <i class="fa-solid fa-person-running fa-fw"></i></a>
                  <a class="btn btn-secondary btn-sm join-item"
                     role="button"
                     data-tippy-content="{% translate "Import" %}"
                     hx-get="{% url 'import_run_add' profile_id=profile.id %}"
                     hx-target="#generic-offcanvas">
                    <i class="fa-solid fa-file-import fa-fw"></i></a>
                  <a class="btn btn-error btn-sm join-item"
                     role="button"
                     data-tippy-content="{% translate "Delete" %}"
                     hx-delete="{% url 'import_profile_delete' profile_id=profile.id %}"
                     hx-trigger='confirmed'
                     data-bypass-on-ctrl="true"
                     data-title="{% translate "Are you sure?" %}"
                     data-text="{% translate "You won't be able to revert this!" %}"
                     data-confirm-text="{% translate "Yes, delete it!" %}"
                     _="install prompt_swal"><i class="fa-solid fa-trash fa-fw"></i></a>
                </div>
              </td>
              <td>{{ profile.name }}</td>
              <td>{{ profile.get_version_display }}</td>
            </tr>
          {% endfor %}
          </tbody>
        </table>
      {% else %}
        <c-msg.empty title="{% translate "No import profiles" %}" remove-padding></c-msg.empty>
      {% endif %}
      </div>
    </div>
  </div>
</div>
