{% extends 'base.html.twig' %}

{% block title %}Список пользователей{% endblock %}

{% block body %}
    <div class="container">

        <a href="{{ path('index_page') }}" class="btn btn-primary float-left mb-4">← Главная</a>
        <a href="{{ path('user_new') }}" class="btn btn-success float-right mb-4">Добавить пользователя</a>
        <div class="table-responsive">
            <table class="table">
                <thead>
                <tr>
                    <th>Id</th>
                    <th>Username</th>
                    <th>Роли</th>
                    <th>Хеш пароля</th>
                    <th>Активный</th>
                    <th>Действия</th>
                </tr>
                </thead>
                <tbody>
                {% for user in users %}
                    <tr>
                        <td>{{ user.id }}</td>
                        <td>{{ user.username }}</td>
                        <td>
                            {% for role in user.roles %}
                                {{ role }},<br>
                            {% endfor %}
                        </td>
                        <td style="max-width: 18.75rem;"><div class="d-inline-block w-100 text-truncate" title="{{ user.password }}">{{ user.password }}</div></td>
                        <td>{{ user.active ? 'Да' : 'Нет' }}</td>
                        <td>
                            <a href="{{ path('user_show', {'id': user.id}) }}" class="btn btn-outline-primary float-right ml-2">Просмотр</a>
                            <a href="{{ path('user_edit', {'id': user.id}) }}" class="btn btn-outline-success float-right">Правка</a>
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td colspan="6">нет записей</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}