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


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


{% block table-header %}
<th style="width: 20%;">{% trans "Type" %}</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: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="item-name">
  {{ item }}
  {% if not item.is_enabled %}
    <small class="text-muted">{{ item.get_status_display }}</small>
  {% endif %}
</td>
<td>
  <ul class="list-unstyled list-inline">
    {% for extension in item.extensions_list %}
      <li>{{ extension }}</li>
    {% endfor %}
  </ul>
</td>
<td>
  {% if item.mimetypes %}
    <ul class="list-unstyled">
      {% for mimetype in item.mimetypes_list %}
        <li>{{ mimetype }}</li>
      {% endfor %}
    </ul>
  {% else %}
    <em>{% trans "None" %}</em>
  {% endif %}
</td>
<td>
  {{ item.num_files }}
</td>
<td class="row-action">
  <a href="{% url 'misago:admin:system:attachment-types:edit' pk=item.pk %}" class="btn btn-primary tooltip-top" title="{% trans "Edit" %}">
    <span class="fa fa-pencil"></span>
  </a>
</td>
<td class="row-action">
  <form action="{% url 'misago:admin:system:attachment-types:delete' pk=item.pk %}" method="post" class="delete-prompt">
    <button class="btn btn-danger tooltip-top" title="{% trans "Delete" %}">
      {% csrf_token %}
      <span class="fa fa-times"></span>
    </button>
  </form>
</td>
{% endblock %}


{% block emptylist %}
<td colspan="{{ 6|add:extra_actions_len }}">
  <p>{% trans "No attachment types are currently defined." %}</p>
</td>
{% endblock emptylist %}


{% block javascripts %}
<script type="text/javascript">
  $(function() {
    $('.delete-prompt').submit(function() {
      var decision = confirm("{% trans "Are you sure you want to delete this attachment type?" %}");
      return decision;
    });
  });
</script>
{% endblock %}
