{% extends "app_home/base.html" %}
{% load i18n %}
{% load static %}

{% block navbar_app %}
{% include 'app_home/_sidebar.html' %}
{% endblock %}

{% block title %}
<h2>{% translate "Permissions" %}</h2>
<small class="text-muted">{{ count }} {% translate "permissions" %}</small>
<hr>{% endblock %}


{% block content %}

{% if bigset %}
<div class="btn-group">

    <div>
    <a class="btn btn-outline-dark" onclick="history.back()" role="button">
    <i class="fa fa-backward" aria-hidden="true"></i>&nbsp; {% translate 'Back' %}</a>
    </div>

    <div class="vr mx-3"></div>

    <div>
    <form class="d-flex" role="search" action="" method="post">{% csrf_token %}
    <button class="btn btn-success" type="submit"><i class="fa fa-search"></i></button> &nbsp;&nbsp;
    <input class="form-control" type="search" name="query" placeholder="{% translate 'Filter' %}" value="{{ query }}">
    </form>
    </div>

    &nbsp;&nbsp;&nbsp;

    {% if page_last > 1 %}
    <div class="my-2">{% translate 'Page' %}</div>
    <div class="mx-3">
    <ul class="pagination mb-0">
      <li class="page-item"><a class="page-link" href="?page={{ page_prev }}&size={{ size }}">&laquo;</a></li>
      <li class="page-item"><a class="page-link {% if page_first %}active{% endif %}" href="?page=1&size={{ size }}">1</a></li>
      &nbsp;&nbsp;&nbsp;
      {% if page_current %}
      <li class="page-item"><a class="page-link active" href="?page={{ page }}&size={{ size }}">{{ page }}</a></li>
      {% else %}
      <li class="page-item"><a class="page-link disabled">...</a></li>
      {% endif %}
      &nbsp;&nbsp;&nbsp;
      <li class="page-item"><a class="page-link {% if page_last_active %}active{% endif %}" href="?page={{ page_last }}&size={{ size }}">{{ page_last }}</a></li>
      <li class="page-item"><a class="page-link" href="?page={{ page_next }}&size={{ size }}">&raquo;</a></li>
    </ul>
    </div>
    {% endif %}

    <div>
      <a class="btn btn-outline-primary dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
      {{ size }} {% translate 'per page' %}</a>
      <div class="dropdown-menu">
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=10">10</a>
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=50">50</a>
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=100">100</a>
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=500">500</a>
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=1000">1000</a>
        <a class="dropdown-item" href="{% url 'app_user:permission_list' %}?size=5000">5000</a>
      </div>
    </div>

</div>
{% endif %}

<hr>

<table class="table table-striped table-hover table-sm small">
<thead class="thead-dark"><tr>
<th>{% translate "Permission" %}</th>
<th>{% translate "Display name" %}</th>
<th>{% translate "Description" %}</th>
<th>{% translate "Built-in" %}</th>
</tr></thead>

{% for p in permissions %}
<tr>
<td class="py-1 px-2 mx-0">{{ p.keyname }}</td>
<td class="py-1 px-1 mx-0">{{ p.displayname|default:'' }}</td>
<td class="py-1 px-1 mx-0">{{ p.description|default:'' }}</td>
<td class="py-1 text-center">{{ p.is_builtin|yesno:"X,," }}</td>
</tr>
{% endfor %}
</table>

{% endblock %}
