From 04c061b7f6ed36281e3b0aa825a9ca14b39629e1 Mon Sep 17 00:00:00 2001 From: afornerot Date: Mon, 28 Oct 2019 15:57:57 +0100 Subject: [PATCH] indicateur des messages non lus en gras (fixes #7) --- .../PortalBundle/Controller/PageController.php | 3 ++- .../WebsocketBundle/Controller/ChatController.php | 10 ++++++++++ .../src/Cadoles/WebsocketBundle/Entity/Message.php | 12 ++++++++++++ .../Resources/views/Chat/client.html.twig | 12 ++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php index a106066a..5a09780f 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php @@ -478,7 +478,7 @@ class PageController extends Controller } // On marque tt les messages comme lu par l'utilisateur - + /* Se fait à présent sur le controleur message au moment meme où l'on affiche l'ensemble des messages if($usage=="group") { // On calcule le nombre de message non lu pour le groupe $group=$em->getRepository("CadolesCoreBundle:Group")->find($groupid); @@ -513,6 +513,7 @@ class PageController extends Controller } } } + */ // Type Calendrier diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php index c4407118..ef63a8ab 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php @@ -57,6 +57,16 @@ class ChatController extends Controller // Récupération des message du groupe $messages=$em->getRepository("CadolesWebsocketBundle:Message")->findBy(["group"=>$group],["submitdate"=>"DESC"],100); + foreach($messages as $message) { + $haveread = ($message->getReaders()->contains($user)); + $message->setHaveread($haveread); + + if(!$haveread) { + $message->addReader($this->getUser()); + $em->persist($message); + $em->flush(); + } + } // Création du formulaire $form = $this->createForm(ChatType::class,null,[]); diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php index 5b15d9b0..55ac5444 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php @@ -58,6 +58,18 @@ class Message */ protected $sees; + + /* champs calculé non stocké en base */ + private $haveread; + public function getHaveread() + { + return $this->haveread; + } + public function setHaveread($haveread) { + $this->haveread = $haveread; + + return $this; + } /** * Constructor diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig index 48ac77ff..4b1b9d92 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Resources/views/Chat/client.html.twig @@ -23,6 +23,10 @@ background-color: #{{ colorbodyback }}; color: #{{ colorbodyfont }}; } + .message-toread { + font-weight:bold; + } + .msgavatar { float:left; height:40px; @@ -65,7 +69,11 @@
{% for message in messages %} -
+ {% set classread="" %} + {% if not message.haveread %} + {% set classread="message-toread" %} + {% endif %} +

{% if fgmanager or message.user == app.user %} @@ -278,7 +286,7 @@ isdeco=false; if(payload.msg) { - html ="
"; + html ="
"; html+="
"; html+="
"; if(payload.msg.userid=={{app.user.id}} || '{{ fgmanager }}'=='1') {