{% extends 'generic/base.html' %}

{% load crispy_forms_tags %}
{% load render_table from django_tables2 %}
{% block css %}
{% endblock %}

{% block content %}
    <a href='{% url "trainees" %}'>Trainees list</a>

    <details class="bulk-edit">
        <summary>
            Bulk edit
        </summary>
        <div id="htmx-info"></div>
        <div id="htmx-options"></div>
        <button id="bulk-delete-supervisors-button"
            title="Deletes the supervisors of all selected users"
            hx-post="{% url 'generic:users_bulk_delete_supervisors' %}"
            hx-include="[name='selection']"
            hx-confirm="This will delete supervisors from all selected users, are you sure you wish to continue?"
            hx-target="#htmx-info"
            _='on click put "" into #htmx-options'
        >Delete supervisors</button>
        <button id="bulk-edit-grade-button"
            hx-post="{% url 'generic:users_bulk_edit' %}"
            hx-include="[name='selection']"
            hx-target="#htmx-options"
            title="Changes the selected users grade."
        
        >Edit grade</button>
        <button id="bulk-add-group-button"
            hx-post="{% url 'generic:users_bulk_edit' %}"
            hx-include="[name='selection']"
            hx-target="#htmx-options"
            title="Adds the selected user to a group."
        
        >Add group</button>
        <button id="bulk-remove-group-button"
            hx-post="{% url 'generic:users_bulk_edit' %}"
            hx-include="[name='selection']"
            hx-target="#htmx-options"
            title="Removes the selected user from a group."
        
        >Remove group</button>
        <button id="bulk-deactivate-user-button"
            hx-post="{% url 'generic:users_bulk_edit' %}"
            hx-include="[name='selection']"
            hx-target="#htmx-options"
            hx-confirm="This will deactivate all selected users, are you sure you wish to continue?"
            title="Deactivates the selected users"
        
        >Deactivate</button>
    </details>

    <div id="table-div">
        <span id="manage-span">
            {% render_table table %}
        </span>
    </div>
    {% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}

    <a href="{% url 'accounts_bulk_create' %}">Bulk create users</a>
    <a href="{% url 'create_user' %}">Create single user</a>


{% endblock %}
