Bee-Lab/BeelabUserBundle

View on GitHub
Resources/views/User/index.html.twig

Summary

Maintainability
Test Coverage
{% extends beelab_user_layout %}

{% block title %}{{ '%entity% list'|trans({'%entity%': 'User'}, 'admin') }} - {{ parent() }}{% endblock %}

{% block body %}
    <h1>{{ '%entity% list'|trans({'%entity%': 'User'}, 'admin') }}</h1>

    <table class="table table-striped table-hover table-bordered records_list">
        <thead>
            <tr>
                <th scope="col">Id</th>
                <th scope="col">{{ 'Email'|trans({}, 'admin') }}</th>
                <th scope="col">{{ 'Active'|trans({}, 'admin') }}</th>
                <th scope="col">{{ 'Last login'|trans({}, 'admin') }}</th>
                <th scope="col">{{ 'Actions'|trans({}, 'admin') }}</th>
            </tr>
        </thead>
        <tbody>
            {% for user in users %}
                <tr>
                    <td><a href="{{ path('user_show', {id: user.id}) }}">{{ user.id }}</a></td>
                    <td>{{ user.email }}</td>
                    <td>{% if user.active %}<i class="fa fa-check"></i>{% endif %}</td>
                    <td>{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %}</td>
                    <td>
                        <div class="btn-group">
                            <a class="btn btn-default btn-sm" href="{{ path('user_show', {id: user.id}) }}">
                                <i class="fa fa-file-o"></i> {{ 'show'|trans({}, 'admin') }}
                            </a>
                            <a class="btn btn-default btn-sm" href="{{ path('user_edit', {id: user.id}) }}">
                                <i class="fa fa-edit"></i> {{ 'edit'|trans({}, 'admin') }}
                            </a>
                            {% if user.active and is_granted('ROLE_ALLOWED_TO_SWITCH') and user != app.user %}
                                <a class="btn btn-default btn-sm" href="{{ path(beelab_user_route, {_switch_user: user.email}) }}">
                                    <i class="fa fa-exchange"></i> {{ 'impersonate'|trans({}, 'admin') }}
                                </a>
                            {% endif %}
                        </div>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

    {% if has_paginator() %}
        {% include 'BeelabUserBundle:User:_paginator.html.twig' with {users: users} %}
    {% endif %}

    <ul class="new_entry list-unstyled">
        <li>
            <a class="btn btn-info" href="{{ path('user_new') }}">
                <i class="fa fa-plus"></i> {{ 'Create a new entry'|trans({}, 'admin') }}
            </a>
        </li>
    </ul>
{% endblock %}