From 03be49bea9c925e7bc59fd413097bacefbcfd166 Mon Sep 17 00:00:00 2001 From: DarckCrystale Date: Tue, 4 Jul 2017 22:21:01 +0200 Subject: [PATCH] Ref #4: jolie liste des notifications --- .../views/notification/liste.html.twig | 131 ++++++++++++------ .../Controller/NotificationController.php | 14 +- 2 files changed, 101 insertions(+), 44 deletions(-) diff --git a/app/Resources/views/notification/liste.html.twig b/app/Resources/views/notification/liste.html.twig index 947e33f..fda424d 100644 --- a/app/Resources/views/notification/liste.html.twig +++ b/app/Resources/views/notification/liste.html.twig @@ -1,49 +1,98 @@ {% extends 'base.html.twig' %} +{% block title %}Notifications{% endblock %} + {% block body %} -

Notifications list

+
+ +

Notifications

+
+ +
+
+ Créer une nouvelle notification +
+ +
+ + + + + + + + + + + + + + + + + {% for notification in notifications %} + + + + + + + + + + + + + {% endfor %} + +
IdIcôneSlugTitreCréateurCréationDescriptionVisibilité
{{ notification.id }} + + {{ notification.slug }}{{ notification.titre }}{{ notification.createur.pseudo }}{% if notification.dateCreation %}{{ notification.dateCreation|localizeddate('none', 'none', 'fr_FR', null, 'd LLL Y') }}
{{ notification.dateCreation|date('H:i') }}{% endif %}
{{ notification.description }} + {% if notification.estPublic %} + + {% else %} + + {% endif %} +
+
+ +
+
+ Créer une nouvelle notification +
- - - - - - - - - - - - - - +
{% for notification in notifications %} -
- - - - - - - - - + {% set form_supprimer = forms_supprimer[notification.id] %} + {% endfor %} - -
IdSlugTitreDescriptionIconeDatecreationEstpublicActions
{{ notification.id }}{{ notification.slug }}{{ notification.titre }}{{ notification.description }}{% if notification.dateCreation %}{{ notification.dateCreation|localizeddate('none', 'none', 'fr_FR', null, 'd LLLL Y') }}
{{ notification.dateCreation|date('H:i') }}{% endif %}
{% if notification.estPublic %}Yes{% else %}No{% endif %} - -
+ - {% endblock %} diff --git a/src/AppBundle/Controller/NotificationController.php b/src/AppBundle/Controller/NotificationController.php index 2b60dab..a0ce42d 100644 --- a/src/AppBundle/Controller/NotificationController.php +++ b/src/AppBundle/Controller/NotificationController.php @@ -25,12 +25,20 @@ class NotificationController extends Controller public function listeAction() { $em = $this->getDoctrine()->getManager(); - $notifications = $em->getRepository('AppBundle:Notification')->findAll(); - return $this->render('notification/liste.html.twig', array( + $deleteForms = []; + + foreach ($notifications as $notification) + { + $deleteForm = $this->createDeleteForm($notification); + $deleteForms[$notification->getId()] = $deleteForm->createView(); + } + + return $this->render('notification/liste.html.twig', [ 'notifications' => $notifications, - )); + 'forms_supprimer' => $deleteForms, + ]); } public function navbarAction()