{% extends app_name|add:'/base.html' %}

{% load crispy_forms_tags %}
{% load render_table from django_tables2 %}

{% block content_container_class %}container-fluid content-wide px-3{% endblock %}

{% block content %}

    <div class="row mb-3">
        <div class="col-12">
            <div class="d-flex justify-content-between mb-2 align-items-center flex-column flex-md-row">
                <div class="mb-2 mb-md-0">
                    <div class="btn-toolbar" role="toolbar">
                        {% if user.is_superuser %}
                            <div class="btn-group me-2" role="group">
                                <button id="delete-selected-btn" class="btn btn-danger btn-sm"
                                        hx-post="{% url 'generic:bulk_delete_questions' %}"
                                        hx-include="[name='selection']:checked"
                                        hx-vals='{"app":"{{ app_name|escapejs }}"}'
                                        hx-target="#action-result"
                                        hx-swap="innerHTML"
                                        hx-confirm="Are you sure you want to delete the selected questions? This action cannot be undone.">Delete selected</button>
                            </div>
                        {% endif %}
                        <div class="btn-group" role="group">
                            <button id="button-select-add-exam" class="btn btn-outline-primary btn-sm"
                                    hx-get="{% url 'generic:generic_exam_htmx' %}?type={{ app_name }}"
                                    hx-target="#action-result"
                                    hx-swap="innerHTML">Add to exam</button>
                        </div>
                    </div>
                </div>
                <div id="action-result" class="mt-2 mt-md-0"></div>
            </div>

            <div class="table-responsive">
                {% render_table table %}
            </div>
        </div>
    </div>


    {% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}

                                                <!-- Minibar: small visible strip when panel is collapsed -->
{% endblock %}

{% block js %}
{% endblock %}