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


{% block page-actions %}
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:users:bans:new' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "New ban" context "admin bans" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th>{% trans "Ban" context "admin bans list" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 200px;">{% trans "Type" context "admin bans list" %}</th>
<th style="width: 250px;">{% trans "Expires on" context "admin bans list" %}</th>
{% for action in extra_actions %}
  <th style="width: 1px;">&nbsp;</th>
{% endfor %}
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="pr-0">
  <a href="{% url 'misago:admin:users:bans:edit' pk=item.pk %}" class="item-name small">
    {{ item.banned_value }}
  </a>
</td>
<td class="badges-list">
  {% if item.registration_only %}
    <span class="badge badge-warning">
      {% trans "Registration only" context "admin ban registration only" %}
    </span>
  {% endif %}
  {% if item.is_expired %}
    <span class="badge badge-dark">
      {% trans "Expired" context "admin ban expired status" %}
    </span>
  {% endif %}
</td>
<td class="small">
  {{ item.get_check_type_display }}
</td>
<td class="small{% if item.is_expired or not item.expires_on %} text-muted{% endif %}">
  {% if item.expires_on %}
    <abbr data-timestamp="{{ item.expires_on.isoformat }}" data-format="LLL">
      {{ item.expires_on }}
    </abbr>
  {% else %}
    <em>{% trans "Never" context "admin ban never expires" %}</em>
  {% endif %}
</td>
{% include "misago/admin/generic/list_extra_actions.html" %}
<td>
  <div class="dropdown">
    <button class="btn btn-light btn-sm dropdown-toggle" type="button" id="item-optioms-{{ item.pk }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <i class="fas fa-ellipsis-h"></i>
    </button>
    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="item-optioms-{{ item.pk }}">
      <a class="dropdown-item" href="{% url 'misago:admin:users:bans:edit' pk=item.pk %}">
        {% trans "Edit ban" context "admin bans" %}
      </a>
      <form action="{% url 'misago:admin:users:bans:delete' pk=item.pk %}" method="post" data-delete-confirmation="true">
        {% csrf_token %}
        <button class="dropdown-item">
          {% trans "Remove ban" context "admin bans" %}
        </button>
      </form>
    </div>
  </div>
</td>
{% endblock %}


{% block blankslate %}
<td colspan="{{ 6|add:extra_actions_len }}">
  {% if active_filters %}
    {% trans "No bans matching criteria exist." context "admin bans" %}
  {% else %}
    {% trans "No bans are set." context "admin bans" %}
  {% endif %}
</td>
{% endblock blankslate %}


{% block javascripts %}
{{ block.super }}
<script type="text/javascript">
  window.misago.initConfirmation(
    "[data-delete-confirmation]",
    "{% trans 'Are you sure you want to remove this ban?' context 'admin bans' %}"
  )
</script>
{% endblock %}


{% block filters-modal-body %}
<div class="row">
  <div class="col">
    {% form_row filter_form.check_type %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.value %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.registration_only %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.state %}
  </div>
</div>
{% endblock filters-modal-body %}

