<!-- table.html -->
{% extends 'frontend/base.html' %}

{% load django_bootstrap5 %}
{% load django_fast_frontend %}

{% block title %}{{ meta.title }}{% endblock %}

{% block content %}
    {% with request.path|split:"/" as segments %}
        <div class="col d-flex justify-content-between">
            {% if option.site.title %}
                <h1>{{ site.title }}</h1>
            {% endif %}
            {% if segments.3 %}
                <a href="{% url 'frontend' app_name=segments.1 model_name=segments.2 %}">{% bootstrap_button button_class="btn-outline-primary" button_type="button" content="Back" %}</a>
            {% endif %}
        </div>
        {% if segments.3 %}
            {% if option.table.add or option.table.change %}
                {% include 'frontend/_form.html' %}
            {% endif %}
        {% else %}
            {% if option.site.description %}
                <div class="col d-flex mb-4">
                    {{ site.description }}
                </div>
            {% endif %}
            {% if option.table.toolbar_button or option.table.add %}
                {% include 'frontend/_toolbar.html' %}
            {% endif %}
            {% if option.table.show %}
                <div class="row">
                    <div class="col d-flex justify-content-end">
                        <div class="p-1">
                            {% if option.table.search %}
                                {% include 'frontend/_search.html' %}
                            {% endif %}
                        </div>
                        <div class="p-1">
{#                            {% if option.table.filter_sort %}#}
                                {% include "frontend/_filter_sort.html" %}
{#                            {% endif %}#}
                        </div>
                    </div>
                </div>
                {% if option.table.cards %}
                    {% include 'frontend/_cards.html' %}
                {% else %}
                    {% include 'frontend/_table.html' %}
                {% endif %}
                {% include 'frontend/_pagination.html' %}
            {% endif %}
        {% endif %}
    {% endwith %}
{% endblock %}
