{% extends "misago/admin/generic/base.html" %}
{% load i18n %}


{% block title %}
{{ active_link.name }} | {{ block.super }}
{% endblock title %}


{% block view %}
<div class="card card-admin-table">
  {% block card-header %}{% endblock card-header %}
  {% if paginator or order_by or filter_form or mass_actions %}
    <div class="card-body">
      <div class="row align-items-center">

        {% if paginator %}
          {% include "misago/admin/generic/paginator.html" %}
        {% endif%}
        {% if order_by %}
          {% include "misago/admin/generic/order_by.html" %}
        {% endif %}
        {% if filter_form %}
          {% include "misago/admin/generic/filter_form.html" %}
        {% endif %}
        {% if mass_actions %}
          {% include "misago/admin/generic/mass_actions.html" %}
        {% endif %}

      </div>
    </div><!-- /.card-body -->
  {% endif %}

  <table class="table">
    <thead>
      <tr>
        {% block table-header %}{% endblock table-header %}
        {% if mass_actions %}
          <th>&nbsp;</th>
        {% endif %}
      </tr>
    </thead>
    <tbody>
      {% block table-items %}
        {% for item in items %}
          <tr>
            {% block table-row %}{% endblock table-row %}
            {% if mass_actions %}
              <td class="row-select">
                <label>
                  <input id="mass-checkbox-{{ item.pk }}" type="checkbox" form="mass-action" name="selected_items" value="{{ item.pk }}" {% if item.pk in selected_items %} checked{% endif %}>
                </label>
              </td>
            {% endif %}
          </tr>
        {% empty %}
          {% block table-row-blankslate %}
            <tr class="blankslate">
              {% block blankslate %}{% endblock blankslate %}
            </tr>
          {% endblock table-row-blankslate %}
        {% endfor %}
      {% endblock table-items %}
    </tbody>
  </table>

  {% if paginator %}
    <div class="card-body">
      <div class="row align-items-center">
        {% include "misago/admin/generic/paginator.html" %}
      </div>
    </div>
  {% endif %}
</div><!-- /.card -->
{% endblock view %}


{% block content %}
{{ block.super }}
{% if filter_form %}
  <div class="modal fade" id="filter-modal" tabindex="-1" role="dialog" aria-labelledby="filter-modal-label" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="filter-modal-label">
            {% block filters-modal-title %}
              {% trans "Filters" %}
            {% endblock filters-modal-title %}
          </h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="{% trans 'Close' %}">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <form method="GET">
          <input type="hidden" name="set_filters" value="1">
          {% for name, value in query_order.items %}
            <input type="hidden" name="{{ name }}" value="{{ value }}">
          {% endfor %}
          <div class="modal-body">
            {% block filters-modal-body %}{% endblock filters-modal-body %}
          </div>
          <div class="modal-footer">
            {% block filters-modal-footer %}
              <button type="button" class="btn btn-light" data-dismiss="modal">
                {% trans "Close" %}
              </button>
              <button type="submit" class="btn btn-primary">
                {% trans "Done" %}
              </button>
            {% endblock filters-modal-footer %}
          </div>
        </form>
      </div>
    </div>
  </div>
{% endif %}
{% endblock content%}


{% block javascripts %}
{% if mass_actions %}
  <script type="text/javascript">
    window.misago.initMassActions("{{ empty_selection_label }}", "{{ selection_label }}")
  </script>
{% endif %}
{% endblock javascripts %}
