{% load django_tables2 i18n %}
{% block table-wrapper %}
  <div class="table-container">
    {% block table %}
      <table {% render_attrs table.attrs %}
          data-click="{{ table.click_action }}" data-url="{{ table.url }}"
          data-pk={{ table.pk }} data-target="{{ table.target }}">
        {% block table.thead %}
          {% if table.show_header %}
            {#  sort attributes and filter row #}
            <thead {{ table.attrs.thead.as_html }} style="margin: 0px">
            <tr class="bg-white">
              {% for column in table.columns %}
                {% if column.name in table.columns_visible %}
                  <th {{ column.attrs.th.as_html }} style="margin: 0px">
                    {% if column.name == "selection" %}
                      <input type="checkbox" id="select_all_page" name="select_all_page" class="ml-2">
                    {% else %}
                      {% if column.orderable %}
                        <a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">
{#                                      <span class="float-right text-white">{% if "-" in column.order_by.0 %}&#9651;{% else %}&#9661;{% endif %}</span>#}
                          {{ column.header }}
                        </a>
                      {% else %}
                        {{ column.header }}
                      {% endif %}
                    {% endif %}
                  </th>
                {% endif %}
              {% endfor %}
            </tr>
            {% if table.filter.style == table.filter.style.HEADER %}
              <tr class="bg-light">
                {% for field in table.header_fields %}
                  <th>
                    {% if field %}
                      {% include "django_tableaux/toolbar/_filter_field.html" with field=field header=True %}
                    {% endif %}
                  </th>
                {% endfor %}
              </tr>
            {% endif %}
            </thead>
          {% endif %}
        {% endblock table.thead %}
        {% block table.tbody %}
          <tbody {{ table.attrs.tbody.as_html }}>
          {% include "django_tableaux/render_table_data.html" %}
          </tbody>
        {% endblock table.tbody %}
        {% block table.tfoot %}
          {% if table.has_footer %}
            <tfoot {{ table.attrs.tfoot.as_html }}>
            <tr>
              {% for column in table.columns %}
                {% if column.name in table.columns_visible %}
                  <td {{ column.attrs.tf.as_html }}>{{ column.footer }}</td>
                {% endif %}
              {% endfor %}
            </tr>
            </tfoot>
          {% endif %}
        {% endblock table.tfoot %}
      </table>
    {% endblock table %}
    {% block pagination %}
      {% if not table.infinite_scroll and not table.infinite_load %}
        {% include "django_tableaux/paginator.html" %}
      {% endif %}
    {% endblock pagination %}
  </div>

{% endblock table-wrapper %}
