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


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


{% block table-header %}
<th>{% trans "Role" %}</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>
{% endblock table-header %}


{% block table-row %}
<td class="item-name">
  {{ item }}
</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:permissions:users:users' pk=item.pk %}" class="btn btn-primary tooltip-top" title="{% trans "Users with role" %}">
    <span class="fa fa-users"></span>
  </a>
</td>
<td class="row-action">
  <a href="{% url 'misago:admin:permissions:users: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:permissions:users: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="{{ 4|add:extra_actions_len }}">
  <p>{% trans "No user roles 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 role?" %}");
      return decision;
    });
  });
</script>
{% endblock %}
