From c49461aa58ed4f61306a97cd2905a6e8f142c9fb Mon Sep 17 00:00:00 2001 From: afornerot Date: Tue, 9 Jun 2020 17:28:47 +0200 Subject: [PATCH] =?UTF-8?q?possibilit=C3=A9=20de=20masquer=20les=20message?= =?UTF-8?q?s=20du=20chat=20(ref=20#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventListener/sessionListener.php | 2 +- .../src/Cadoles/CoreBundle/Form/UserType.php | 2 +- .../Resources/views/User/view.html.twig | 2 +- .../Controller/ChatController.php | 5 +- .../WebsocketBundle/Entity/Message.php | 13 +++- .../Resources/views/Chat/client.html.twig | 63 ++++++++++++++++--- 6 files changed, 75 insertions(+), 12 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php index ea2ea5e1..c83fdffd 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/sessionListener.php @@ -286,7 +286,7 @@ } if($curentuser!="anon.") { - $visitedate=$curentuser->getVisitedate(); + $visitedate=clone $curentuser->getVisitedate(); if($visitedate) $visitedate->add(new \DateInterval("PT1H")); $now=new \DateTime(); if($visitedate<$now) { diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php index a787af90..7ccbefd2 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/UserType.php @@ -378,7 +378,7 @@ class UserType extends AbstractType $builder->add('visitedate', DateTimeType::class, [ "label" => 'Date de dernière visite', "disabled" => true, - "required" => ($fields["visite"]["perm"]==2), + "required" => ($fields["visite"]["perm"]==2), "widget" => 'single_text', ]); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig index 103beb28..341f3c4c 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/User/view.html.twig @@ -19,7 +19,7 @@ {%if user.job %}Métier = {{ user.job }}
{%endif%} {%if user.position %}Fonction = {{ user.position }}
{%endif%} {%if user.postaladress %}Adresse = {{ user.postaladress }}
{%endif%} - {%if user.visitedate %}Date de dernière visite = {{ user.visitedate|date("d/m/Y H:i") }}
{%endif%} + {%if user.visitedate %}Date de dernière visite = {{ user.visitedate|date('d/m/Y H:i') }}
{%endif%} {%if user.visitecpt %}Nombre de visites = {{ user.visitecpt }}
{%endif%}
{% set fgtitle=false %} 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 28fc7484..a245ce2a 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Controller/ChatController.php @@ -59,8 +59,11 @@ class ChatController extends Controller $messages=$em->getRepository("CadolesWebsocketBundle:Message")->findBy(["group"=>$group],["submitdate"=>"DESC"],30); foreach($messages as $message) { $haveread = ($message->getReaders()->contains($user)); - $message->setHaveread($haveread); + $havesee = ($message->getSees()->contains($user)); + $message->setHaveread($haveread); + $message->setHavesee($havesee); + if(!$haveread) { $message->addReader($this->getUser()); $em->persist($message); 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 55ac5444..e9b692a2 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Entity/Message.php @@ -70,7 +70,18 @@ class Message return $this; } - + + private $havesee; + public function getHavesee() + { + return $this->havesee; + } + public function setHavesee($havesee) { + $this->havesee = $havesee; + + 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 87f21ffb..7f71eb23 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 @@ -30,6 +30,9 @@ .message-toread { font-weight:bold; } + .message-see { + display:none; + } .msgavatar { float:left; @@ -63,10 +66,12 @@ {{ form_start(form) }}
{{ form_widget(form.message) }} - - + + Envoyer
+ +
@@ -77,11 +82,20 @@ {% if not message.haveread %} {% set classread="message-toread" %} {% endif %} -
+ + {% set classsee="" %} + {% if message.havesee %} + {% set classsee="message-see" %} + {% endif %} + +

{% if fgmanager or message.user == app.user %} - + + {% endif %} + {% if not message.havesee %} + {% endif %}
@@ -294,8 +308,10 @@ html+="
"; html+="
"; if(payload.msg.userid=={{app.user.id}} || '{{ fgmanager }}'=='1') { - html+=""; + html+=""; } + html+=""; + html+="
"; html+="
" html+="
"+payload.msg.lastname+"
"+new Date(payload.msg.submitdate.date).toLocaleDateString("fr-FR", dateoptions)+"
"; @@ -350,6 +366,13 @@ isdeco=true; }); } + + function switchsee() { + $(".message-see").hide(); + if($("#unsee").bootstrapSwitch('state')) { + $(".message-see").show(); + } + } $( "#sendbtn" ).click(function() { sendbtn(); @@ -469,6 +492,31 @@ } } + $(document).on('click', '.hidemessage', function(){ + hidemessage($(this).data("id")); + }); + + function hidemessage(id) { + $.ajax({ + method: "POST", + url: "{{ path('cadoles_websocket_message_see') }}", + data: { + id:id + }, + success: function() { + $("#message-"+id).addClass ("message-see"); + $("#hidemessage-"+id).remove(); + + if(!$("#unsee").bootstrapSwitch('state')) { + $("#message-"+id).hide(); + } + else { + $("#message-"+id).show(); + } + } + }); + + } $(document).on('click', '#listtoavatar img', function(){ var mail = ";"+$(this).data("mail"); $("#mailto").val($("#mailto").val().replace(mail, "")); @@ -521,8 +569,9 @@ function addOnline(userid, useravatar, userlastname, userfirstname) { if(!$("#online"+userid).length) { - html = ""; - html+= ""; + html = ""; + html+= ""; + html+= userlastname+" "+userfirstname; html+= ""; $("#useronline").append(html); }