{% extends 'base.html.twig' %}
{% set menu = 'resources' %}

{% block body %}

<h1 class="display-4 d-flex font-weight-lighter justify-content-between">{{ "title.users_and_resources"|trans }}<a href="{{ path('user_create') }}" class="btn btn-sm btn-success mb-auto mt-auto">+ {{ "users.new"|trans }}</a></h1>

<div class="list-group mt-5">
{% for principal in principals %}
    <div class="list-group-item list-group-item-action p-3">
        <div class="d-flex w-100 justify-content-between">
            <h5 class="mr-auto">{{ principal.displayName }} <a href="mailto:{{ principal.email }}">&lsaquo;{{ principal.email }}&rsaquo;</a></h5>

            <div class="mr-0 text-right d-lg-block d-none">
                <a href="{{ path('delegates',{username: principal.username}) }}" class="btn btn-sm btn-outline-secondary mb-1">💁&nbsp;{{ "users.delegates"|trans }}</a>
                <a href="{{ path('calendars',{username: principal.username}) }}" class="btn btn-sm btn-outline-secondary mb-1">🗓&nbsp;{{ "users.calendars"|trans }}</a>
                <a href="{{ path('address_books',{username: principal.username})}}" class="btn btn-sm btn-outline-secondary ml-1 mb-1">📖&nbsp;{{ "users.addressbooks"|trans }}</a>
                <a href="{{ path('user_edit',{username: principal.username})}}" class="btn btn-sm btn-outline-primary ml-1 mb-1">✎&nbsp;{{ "edit"|trans }}</a>
                <a href="#" data-href="{{ path('user_delete',{username: principal.username})}}" class="btn btn-sm btn-outline-danger ml-1 mb-1 delete-modal" data-flavour="users">⚠&nbsp;{{ "delete"|trans }}</a>
            </div>
        </div>
        <p class="mb-1">{{ "users.username"|trans }} : <code>{{ principal.username }}</code></p>
        <small>{{ "users.uri"|trans }} : <code>{{ principal.uri }}</code>{% if principal.isAdmin %} — <span class="badge badge-primary">{{ "users.administrator"|trans }}</span>{% endif %}</small>
        <div class="btn-group btn-group-sm mt-3 d-flex d-lg-none" role="group">
            <a href="{{ path('delegates',{username: principal.username}) }}" class="btn btn-outline-secondary flex-fill w-100"><span class="d-none d-sm-inline">💁&nbsp;</span>{{ "users.delegates"|trans }}</a>
            <a href="{{ path('calendars',{username: principal.username}) }}" class="btn btn-outline-secondary flex-fill w-100"><span class="d-none d-sm-inline">🗓&nbsp;</span>{{ "users.calendars"|trans }}</a>
            <a href="{{ path('address_books',{username: principal.username})}}" class="btn btn-outline-secondary flex-fill w-100"><span class="d-none d-sm-inline">📖&nbsp;</span>{{ "users.addressbooks"|trans }}</a>
            <a href="{{ path('user_edit',{username: principal.username})}}" class="btn btn-outline-primary flex-fill flex-shrink-1"><span class="d-none d-sm-inline">✎&nbsp;</span>{{ "edit"|trans }}</a>
            <a href="#" data-href="{{ path('user_delete',{username: principal.username})}}" class="btn btn-outline-danger flex-fill flex-shrink-1 delete-modal" data-flavour="users"><span class="d-none d-sm-inline">⚠&nbsp;</span>{{ "delete"|trans }}</a>
        </div>
    </div>
{% else %}
    <div class="my-5 py-5 d-flex justify-content-center align-items-center text-muted">{{ "no.users.yet"|trans }}</div>
{% endfor %}
</div>

{% include '_partials/delete_modal.html.twig' with {flavour: 'users'} %}

{% endblock %}