From 897b9130c17ed0c52f36542063ee59ceaf4d0b0e Mon Sep 17 00:00:00 2001 From: Aymeric SERRA Date: Fri, 10 Feb 2023 17:41:48 +0100 Subject: [PATCH 1/4] Ammelioration de la vue de la liste des utilisateurs --- src/Entity/User.php | 8 +++++ templates/user/index.html.twig | 61 ++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/Entity/User.php b/src/Entity/User.php index 3a5ee84..3e67c34 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -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; diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig index e2e3f7f..505c627 100644 --- a/templates/user/index.html.twig +++ b/templates/user/index.html.twig @@ -3,39 +3,42 @@ {% block title %}User index{% endblock %} {% block body %} -

User index

+
+
+

Liste des Utilisateurs

+
- - +
+
+ - - - - + + + - - - {% for user in users %} - - - - - - - - - {% else %} - - - - {% endfor %} - -
IdEmailRoles Nom PrenomactionsEmailRolesActions
{{ user.id }}{{ user.email }}{{ user.roles ? user.roles[0] : '' }}{{ user.nom }}{{ user.prenom }} - show - edit -
no records found
+ + + {% for user in users %} + + {{ user.nom }} + {{ user.prenom }} + {{ user.email }} + {{ user.nomRole }} + Voir + + {% else %} + + no records found + + {% endfor %} + + +
- Create new + + {% endblock %} From 0a54d50934a0ffcaedbf2e7b1b20b5d404095602 Mon Sep 17 00:00:00 2001 From: Aymeric SERRA Date: Fri, 10 Feb 2023 17:55:21 +0100 Subject: [PATCH 2/4] Modification style page pour voir un utilisateur --- templates/user/_delete_form.html.twig | 4 +- templates/user/show.html.twig | 65 +++++++++++++++------------ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/templates/user/_delete_form.html.twig b/templates/user/_delete_form.html.twig index 6d59fa6..525de68 100644 --- a/templates/user/_delete_form.html.twig +++ b/templates/user/_delete_form.html.twig @@ -1,4 +1,4 @@ -
+ - +
diff --git a/templates/user/show.html.twig b/templates/user/show.html.twig index ffc5b61..ecefb36 100644 --- a/templates/user/show.html.twig +++ b/templates/user/show.html.twig @@ -3,36 +3,45 @@ {% block title %}User{% endblock %} {% block body %} -

User

+
+
+

Utilisateur

+
- - - - - - - - - - - - - - - - - - - - - - - -
Id{{ user.id }}
Email{{ user.email }}
Roles{{ user.roles ? user.roles[0] : '' }}
Nom{{ user.nom }}
Prenom{{ user.prenom }}
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Id{{ user.id }}
Email{{ user.email }}
Roles{{ user.roles ? user.roles[0] : '' }}
Nom{{ user.nom }}
Prenom{{ user.prenom }}
+
- back to list + +
{% endblock %} From 6dd51be9cfab43c320f1c2104b494b686b4c6a90 Mon Sep 17 00:00:00 2001 From: Aymeric SERRA Date: Fri, 10 Feb 2023 18:07:51 +0100 Subject: [PATCH 3/4] Modification style page pour modifier un utilisateur --- templates/user/_delete_form.html.twig | 2 +- templates/user/_form.html.twig | 20 ++++++++++++++++++-- templates/user/edit.html.twig | 17 +++++++++++++---- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/templates/user/_delete_form.html.twig b/templates/user/_delete_form.html.twig index 525de68..c1f0617 100644 --- a/templates/user/_delete_form.html.twig +++ b/templates/user/_delete_form.html.twig @@ -1,4 +1,4 @@
- +
diff --git a/templates/user/_form.html.twig b/templates/user/_form.html.twig index bf20b98..2068256 100644 --- a/templates/user/_form.html.twig +++ b/templates/user/_form.html.twig @@ -1,4 +1,20 @@ {{ form_start(form) }} - {{ form_widget(form) }} - + {{ form_row(form.email) }} +
+
+ {{ form_row(form.nom) }} +
+
+ {{ form_row(form.prenom) }} +
+
+ +{% if form.plainPassword is defined %} + {{ form_row(form.plainPassword) }} +{% endif %} +{{ form_row(form.roles) }} + +
+ +
{{ form_end(form) }} diff --git a/templates/user/edit.html.twig b/templates/user/edit.html.twig index 141d94a..5453edb 100644 --- a/templates/user/edit.html.twig +++ b/templates/user/edit.html.twig @@ -3,11 +3,20 @@ {% block title %}Edit User{% endblock %} {% block body %} -

Edit User

+
+
+

Modifier l'utilisateur

+
- {{ include('user/_form.html.twig', {'button_label': 'Update'}) }} +
+ {{ include('user/_form.html.twig', {'button_label': 'Mettre à jour'}) }} +
- back to list + +
{% endblock %} From ba7e2a60c62a212c46efaddc8a3704bf116fbfca Mon Sep 17 00:00:00 2001 From: Aymeric SERRA Date: Fri, 10 Feb 2023 18:13:07 +0100 Subject: [PATCH 4/4] Modification style page pour ajouter un utilisateur --- templates/user/_form.html.twig | 2 +- templates/user/new.html.twig | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/templates/user/_form.html.twig b/templates/user/_form.html.twig index 2068256..d137888 100644 --- a/templates/user/_form.html.twig +++ b/templates/user/_form.html.twig @@ -15,6 +15,6 @@ {{ form_row(form.roles) }}
- +
{{ form_end(form) }} diff --git a/templates/user/new.html.twig b/templates/user/new.html.twig index 35e728d..f624369 100644 --- a/templates/user/new.html.twig +++ b/templates/user/new.html.twig @@ -3,9 +3,19 @@ {% block title %}New User{% endblock %} {% block body %} -

Create new User

+
+
+

Ajouter un utilisateur

+
- {{ include('user/_form.html.twig') }} - back to list +
+ {{ include('user/_form.html.twig') }} +
+ + +
{% endblock %}