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

{% if results %}
  <div class="results">
    <table id="result_list" class="table table-striped table-hover">
      <thead>
        <tr>
          {% for header in result_headers %}
            <th scope="col" {{ header.class_attrib }}>
              <div class="text text-body-emphasis">
                {% if header.sortable %}

                  {% if header.sort_priority > 0 %}

                    {% if num_sorted_fields > 1 %}
                      <span class="sortpriority badge bg-secondary" title="{% blocktrans with priority_number=header.sort_priority %}Sorting priority: {{ priority_number }}{% endblocktrans %}">{{ header.sort_priority }}</span>
                    {% endif %}

                    <a class="sortremove text-danger-emphasis" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"><i class="fa fa-times"></i></a>
                  {% endif %}

                  <a href="{{ header.url_primary }}" class="link-body-emphasis">{{ header.text|capfirst }}</a>
                  <a href="{{ header.url_primary }}" class="link-body-emphasis">{% if header.ascending %}<i class="fa fa-sort-up"></i>{% else %}<i class="fa fa-sort-down"></i>{% endif %}</a>
                {% else %}
                  <span>{{ header.text|capfirst }}</span>
                {% endif %}
              </div>
            </th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
        {% for result in results %}
          {% if result.form.non_field_errors %}
            <tr><td colspan="{{ result|length }}">{{ result.form.non_field_errors }}</td></tr>
          {% endif %}
          <tr>{% for item in result %}{{ item }}{% endfor %}</tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endif %}
