{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}

{% if dataTable is not defined and page_setup is defined and page_setup.hasDataTable() %}
    {% set dataTable = page_setup.getDataTable() %}
{% endif %}

{% block main_before %}
    {{ tables.configuration(dataTable) }}
{% endblock %}

{% block table_actions %}
    {{ tables.actions(dataTable) }}
{% endblock %}

{% block status %}
    {% if dataTable.getPagination() is not null %}
        {% from "macros/status.html.twig" import status_count %}
        {{ status_count(dataTable.getPagination().getNbResults()) }}
    {% endif %}
{% endblock %}

{% block main %}

    {% if not dataTable.hasResults() %}
        {{ widgets.nothing_found(dataTable.getReloadEvents()) }}
    {% else %}
        {{ tables.header(dataTable) }}

        {% block datatable_before %}{% endblock %}

        {% set sortedColumns = dataTable.sortedColumnNames %}
        {% block datatable_outer %}
            {% for entry in dataTable %}
                {% block datatable_row %}
                    <tr{% block datatable_row_attr %}{% endblock %}>
                        {% for column, data in sortedColumns %}
                            {% block datatable_column %}
                                <td class="{{ tables.class(dataTable, column) }}"{% block datatable_column_attr %}{% endblock %}>
                                    {% block datatable_column_value %}{% endblock %}
                                </td>
                            {% endblock %}
                        {% endfor %}
                    </tr>
                {% endblock %}
            {% endfor %}
        {% endblock %}

        {% block datatable_after %}{% endblock %}

        {{ tables.footer(dataTable) }}
    {% endif %}

{% endblock %}
