{% load static %}

{% if result_hidden_fields %}
    <div class="hiddenfields">
        {% for item in result_hidden_fields %}{{ item }}{% endfor %}
    </div>
{% endif %}

{% if not results %}
    <h5 class="kt-font-bold m-4">Nenhum registro encontrado</h5>
{% else %}
<table class="table kt-datatable__table table-striped table-hover" id="changelist-table">
    <thead class="kt-datatable__head">
    <tr class="kt-datatable__row">
        {% for header in result_headers %}
            <th scope="col" {{ header.class_attrib }}>
                <div class="text d-inline-flex">
                    {% if header.sortable %}
                        {% if header.sort_priority > 0 %}
                            <div class="sortoptions mr-1">
                                <a class="sortremove" href="{{ header.url_remove }}"
                                   title="Remover do Filtro">
                                    <i class="text-danger fas fa-times"></i>
                                </a>
                                {% if num_sorted_fields > 1 %}
                                    <span class="sortpriority"
                                          title="Prioridade: {{ header.sort_priority }}">
                                    {{ header.sort_priority }}
                                </span>
                                {% endif %}
                                <a href="{{ header.url_toggle }}"
                                   class="toggle {% if header.ascending %}ascending{% else %}descending{% endif %}"
                                   title="Ativar / Desativar Ordenação">
                                    {% if header.ascending %}
                                        <i class="text-dark  fas fa-arrow-up"></i>
                                    {% else %}
                                        <i class="text-dark  fas fa-arrow-down"></i>
                                    {% endif %}
                                </a>
                            </div>
                        {% endif %}
                    {% endif %}
                    {% if header.sortable %}
                        <a class="kt-font-bold" href="{{ header.url_primary }}">
                            {{ header.text|capfirst }}</a>
                    {% else %}
                        <span class="kt-font-bold">{{ header.text|capfirst }}</span>
                    {% endif %}
                </div>
                <div class="clear"></div>
            </th>
        {% endfor %}
    </tr>
    </thead>
    <tbody class="kt-datatable__body">
    {% for result in results %}
        {% if result.form and result.form.non_field_errors %}
            <tr class="kt-datatable__row">
                <td colspan="{{ result|length }}">
                    {{ result.form.non_field_errors }}
                </td>
            </tr>
        {% endif %}
        <tr class="kt-datatable__cell kt-font-bold {% cycle 'row1' 'row2' %}">
            {% for item in result %}
                {{ item }}
            {% endfor %}
        </tr>
    {% endfor %}
    </tbody>

</table>
{% endif %}
