{% extends 'base.html' %}
{% block content %}
<div class="container-fluid mt-0">
    <h1>{{ _("Roles") }}</h1>
    <h2>{{ _("This page configures the possible roles of FabLab users.") }}</h2>
    <a href="{{ url_for('add_role') }}" class="btn btn-primary mb-3">{{ _("Add Role") }}</a>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>{{ _("Name") }}</th>
                <th class="d-none d-lg-table-cell">{{ _("Reserved") }}</th>
                <th>{{ _("Backend admin?") }}</th>
                <th>{{ _("Maintainer?") }}</th>
                <th>{{ _("Authorize All?") }}</th>
                <th>{{ _("Action") }}</th>
            </tr>
        </thead>
        <tbody>
            {% for role in roles %}
            <tr>
                <td>{{ role.role_id }}</td>
                <td>{{ role.role_name }}</td>
                <td class="d-none d-lg-table-cell">
                    {% if role.reserved %}
                    <i class="fa-solid fa-lock"></i> <!-- Locked Icon -->
                    {% else %}
                    <i class="fa-solid fa-lock-open"></i> <!-- Unlocked Icon -->
                    {% endif %}
                </td>
                <td>
                    {% if role.backend_admin %}
                    <i class="fa fa-check" aria-hidden="true"></i>
                    {% else %}
                    <i class="fa fa-times" aria-hidden="true"></i>
                    {% endif %}
                </td>
                <td>
                    {% if role.maintenance %}
                    <i class="fa fa-check" aria-hidden="true"></i>
                    {% else %}
                    <i class="fa fa-times" aria-hidden="true"></i>
                    {% endif %}
                </td>
                <td>
                    {% if role.authorize_all %}
                    <i class="fa fa-check" aria-hidden="true"></i>
                    {% else %}
                    <i class="fa fa-times" aria-hidden="true"></i>
                    {% endif %}
                </td>
                <td>
                    {% if not role.reserved %}
                    <a href="{{ url_for('edit_role', role_id=role.role_id) }}" class="btn btn-warning">{{ _("Edit") }}</a>
                    <a href="{{ url_for('delete_role', role_id=role.role_id) }}" class="btn btn-danger">{{ _("Delete") }}</a>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}