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


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


{% block table-header %}
<th style="width: 25%;">{% trans "Rank" %}</th>
<th>{% trans "Title" %}</th>
<th style="width: 120px;">{% trans "Special" %}</th>
{% for action in extra_actions %}
<th style="width: 1%;">&nbsp;</th>
{% endfor %}
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="item-name">
  {{ item }}
</td>
<td>
  {% if item.title %}
    {{ item.title }}
  {% else %}
  <i class="text-muted">{% trans "No title set" %}</i>
  {% endif %}
</td>
<td class="lead text-muted">
  {% if item.is_tab %}
  <div class="fa fa-list tooltip-top" title="{% trans "Has page on users list." %}"></div>
  {% endif %}
  {% if item.is_default %}
  <div class="fa fa-star tooltip-top" title="{% trans "This is default rank assigned to new members." %}"></div>
  {% endif %}
</td>
{% for action in extra_actions %}
<td class="row-action">
  <a href="{% url action.link pk=item.pk %}" class="btn btn-{% if action.style %}{{ action.style }}{% else %}default{% endif %} tooltip-top" title="{{ action.name }}">
    <span class="{{ action.icon }}"></span>
  </a>
</td>
{% endfor %}
<td class="row-action">
  <a href="{% url 'misago:admin:users:ranks:users' pk=item.pk %}" class="btn btn-primary tooltip-top" title="{% trans "Users with rank" %}">
    <span class="fa fa-users"></span>
  </a>
</td>
<td class="row-action">
  {% if not item.is_default %}
  <form action="{% url 'misago:admin:users:ranks:default' pk=item.pk %}" method="post">
    <button class="btn btn-warning tooltip-top" title="{% trans "Make default" %}">
      {% csrf_token %}
      <span class="fa fa-star"></span>
    </button>
  </form>
  {% else %}
  &nbsp;
  {% endif %}
</td>
<td class="row-action">
  {% if not forloop.last %}
  <form action="{% url 'misago:admin:users:ranks:down' pk=item.pk %}" method="post">
    <button class="btn btn-default tooltip-top" title="{% trans "Move down" %}">
      {% csrf_token %}
      <span class="fa fa-chevron-down"></span>
    </button>
  </form>
  {% else %}
  &nbsp;
  {% endif %}
</td>
<td class="row-action">
  {% if not forloop.first %}
  <form action="{% url 'misago:admin:users:ranks:up' pk=item.pk %}" method="post">
    <button class="btn btn-default tooltip-top" title="{% trans "Move up" %}">
      {% csrf_token %}
      <span class="fa fa-chevron-up"></span>
    </button>
  </form>
  {% else %}
  &nbsp;
  {% endif %}
</td>
<td class="row-action">
  <a href="{% url 'misago:admin:users:ranks: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:users:ranks: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="{{ 8|add:extra_actions_len }}">
  <p>{% trans "No ranks 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 rank?" %}");
      return decision;
    });
  });
</script>
{% endblock %}
