Ammelioration de la vue de la liste des utilisateurs

This commit is contained in:
Aymeric SERRA 2023-02-10 17:41:48 +01:00
parent 3dba806953
commit 897b9130c1
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
2 changed files with 40 additions and 29 deletions

View File

@ -90,6 +90,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return array_unique($roles);
}
public function getNomRole() : string {
return match ($this->getRoles()[0]) {
'ROLE_ADMINISTRATEUR' => 'Administrateur',
'ROLE_INSTRUCTEUR' => 'Instructeur',
default => 'Apprenti'
};
}
public function setRoles(array $roles): self
{
$this->roles = $roles;

View File

@ -3,31 +3,30 @@
{% block title %}User index{% endblock %}
{% block body %}
<h1>User index</h1>
<div class="card mb-4">
<div class="card-header">
<h1 class="card-title">Liste des Utilisateurs</h1>
</div>
<table class="table">
<div class="card-body table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>Roles</th>
<th>Nom</th>
<th>Prenom</th>
<th>actions</th>
<th>Email</th>
<th>Roles</th>
<th style="text-align: center;">Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.email }}</td>
<td>{{ user.roles ? user.roles[0] : '' }}</td>
<td>{{ user.nom }}</td>
<td>{{ user.prenom }}</td>
<td>
<a href="{{ path('app_user_show', {'id': user.id}) }}">show</a>
<a href="{{ path('app_user_edit', {'id': user.id}) }}">edit</a>
</td>
<td>{{ user.email }}</td>
<td>{{ user.nomRole }}</td>
<td style="text-align: center;"><a class="btn btn-primary" href="{{ path('app_user_show', {'id': user.id}) }}">Voir</a></td>
</tr>
{% else %}
<tr>
@ -36,6 +35,10 @@
{% endfor %}
</tbody>
</table>
</div>
<a href="{{ path('app_user_new') }}">Create new</a>
<div class="card-footer">
<a class="btn btn-primary" href="{{ path('app_user_new') }}">Créer un Utilisateur</a>
</div>
</div>
{% endblock %}