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


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


{% block table-header %}
<th>{% trans "Type" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 20%;">{% trans "Extensions" %}</th>
<th style="width: 20%;">{% trans "Mimetypes" %}</th>
<th style="width: 20%;">{% trans "Files" %}</th>
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="small pr-0">
  <a href="{% url 'misago:admin:settings:attachment-types:edit' pk=item.pk %}" class="item-name">
    {{ item }}
  </a>
</td>
<td class="badges-list">
  {% if item.is_locked %}
    <span class="badge badge-warning" data-tooltip="top" title="{% trans 'Uploading new files of this type is disabled' %}">
      {% trans "Limited" %}
    </span>
  {% elif not item.is_enabled %}
    <span class="badge badge-dark" data-tooltip="top" title="{% trans 'Uploading and downloading files of this type is disabled' %}">
      {% trans "Disabled" %}
    </span>
  {% endif %}
</td>
<td class="small">
  <ul class="list-unstyled m-0">
    {% for extension in item.extensions_list %}
      <li>{{ extension }}</li>
    {% endfor %}
  </ul>
</td>
<td class="small">
  {% if item.mimetypes %}
    <ul class="list-unstyled m-0">
      {% for mimetype in item.mimetypes_list %}
        <li>{{ mimetype }}</li>
      {% endfor %}
    </ul>
  {% else %}
    <em class="text-muted">{% trans "Not set" %}</em>
  {% endif %}
</td>
<td class="small">
  {{ item.num_files }}
</td>
<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:settings:attachment-types:edit' pk=item.pk %}">
        {% trans "Edit type" %}
      </a>
      <form action="{% url 'misago:admin:settings:attachment-types:delete' pk=item.pk %}" method="post" class="delete-prompt">
        {% csrf_token %}
        <button class="dropdown-item">
          {% trans "Delete type" %}
        </button>
      </form>
    </div>
  </div>
</td>
{% endblock %}


{% block blankslate %}
<td colspan="{{ 6 }}">
  {% trans "No attachment types are set." %}
</td>
{% endblock blankslate %}


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