possibilité de masquer les messages du chat (ref #155)
This commit is contained in:
parent
2a1179ae9a
commit
c49461aa58
@ -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) {
|
||||
|
@ -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',
|
||||
]);
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
{%if user.job %}<b>Métier</b> = {{ user.job }}<br>{%endif%}
|
||||
{%if user.position %}<b>Fonction</b> = {{ user.position }}<br>{%endif%}
|
||||
{%if user.postaladress %}<b>Adresse</b> = {{ user.postaladress }}<br>{%endif%}
|
||||
{%if user.visitedate %}<b>Date de dernière visite</b> = {{ user.visitedate|date("d/m/Y H:i") }}<br>{%endif%}
|
||||
{%if user.visitedate %}<b>Date de dernière visite</b> = {{ user.visitedate|date('d/m/Y H:i') }}<br>{%endif%}
|
||||
{%if user.visitecpt %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
|
||||
<br>
|
||||
{% set fgtitle=false %}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -30,6 +30,9 @@
|
||||
.message-toread {
|
||||
font-weight:bold;
|
||||
}
|
||||
.message-see {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.msgavatar {
|
||||
float:left;
|
||||
@ -63,10 +66,12 @@
|
||||
{{ form_start(form) }}
|
||||
<div id="topchat" class='row'>
|
||||
{{ form_widget(form.message) }}
|
||||
<input id="sendbymail" type="checkbox" id="item_essential" name="item[essential]" style="float:right" class='switch' ></input>
|
||||
<label class="custom-control-label" for="sendbymail">Envoyer par Mail ?</label>
|
||||
<input id="sendbymail" type="checkbox" style="float:right" class='switch' ></input>
|
||||
<label class="custom-control-label" for="sendbymail" style="color:#{{ colorbodyback }}">Envoyer par Mail ?</label>
|
||||
<a id="sendbtn" class="btn btn-success" style="margin-top:5px; width:100%; margin-bottom:15px">Envoyer</a>
|
||||
<div id="useronline" style="margin-bottom:10px"></div>
|
||||
<input id="unsee" type="checkbox" style="float:right" class='switch' onChange="switchsee()"></input>
|
||||
<label class="custom-control-label" for="unsee" style="color:#{{ colorbodyback }}">Afficher les message masquer ?</label>
|
||||
</div>
|
||||
|
||||
|
||||
@ -77,11 +82,20 @@
|
||||
{% if not message.haveread %}
|
||||
{% set classread="message-toread" %}
|
||||
{% endif %}
|
||||
<div id='message-{{message.id}}' class='message row {{classread}}'>
|
||||
|
||||
{% set classsee="" %}
|
||||
{% if message.havesee %}
|
||||
{% set classsee="message-see" %}
|
||||
{% endif %}
|
||||
|
||||
<div id='message-{{message.id}}' class='message row {{classread}} {{classsee}}'>
|
||||
<div class='msgavatar'>
|
||||
<img style='cursor:pointer' onclick='seeUser({{message.user.id}})' id='user_avatar_img' src='/{{ alias }}/uploads/avatar/{{message.user.avatar}}' class='avatar'><br>
|
||||
{% if fgmanager or message.user == app.user %}
|
||||
<i class='delmessage fa fa-trash fa-fw' data-id='{{message.id}}' style='cursor: pointer;'></i>
|
||||
<i class='delmessage fa fa-trash fa-fw' data-id='{{message.id}}' title='Supprimer' style='cursor: pointer;'></i>
|
||||
{% endif %}
|
||||
{% if not message.havesee %}
|
||||
<i id="hidemessage-{{message.id}}" class='hidemessage fa fa-eye-slash fa-fw' title='Ne plus afficher' data-id='{{message.id}}' style='cursor: pointer;'></i>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class='msgdiv'>
|
||||
@ -294,8 +308,10 @@
|
||||
html+="<div class='msgavatar'>";
|
||||
html+="<img style='pointer:cursor' onclick='seeUser("+payload.msg.userid+")' id='user_avatar_img' src='/{{ alias }}/uploads/avatar/"+payload.msg.avatar+"' class='avatar'><br>";
|
||||
if(payload.msg.userid=={{app.user.id}} || '{{ fgmanager }}'=='1') {
|
||||
html+="<i class='delmessage fa fa-trash fa-fw' data-id='"+payload.msg.id+"' style='cursor: pointer;'></i>";
|
||||
html+="<i class='delmessage fa fa-trash fa-fw' data-id='"+payload.msg.id+"' title='Supprimer' style='cursor: pointer;'></i>";
|
||||
}
|
||||
html+="<i id='hidemessage-"+payload.msg.id+"' class='hidemessage fa fa-eye-slash fa-fw' data-id='"+payload.msg.id+"' title='Ne plus afficher' style='cursor: pointer;'></i>";
|
||||
|
||||
html+="</div>";
|
||||
html+="<div class='msgdiv'>"
|
||||
html+="<div class='msgtitle'>"+payload.msg.lastname+"<br><small>"+new Date(payload.msg.submitdate.date).toLocaleDateString("fr-FR", dateoptions)+"</small></div>";
|
||||
@ -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 = "<span id='online"+userid+"'>";
|
||||
html+= "<img style='cursor:pointer; width:30px; height:30px; margin-right:5px;' onclick='seeUser("+userid+")' title='"+userlastname+" "+userfirstname+"' id='user_avatar_img' src='/{{ alias }}/uploads/avatar/"+useravatar+"' class='avatar'>";
|
||||
html = "<span id='online"+userid+"' style='width:70px; height:105px; display:inline-block; text-align: center; font-size: 10px; color:#{{ colorbodyback }}; text-transform: uppercase; line-height:11px;overflow-wrap: break-word;vertical-align:top;'>";
|
||||
html+= "<img style='cursor:pointer; width:40px; height:40px; margin-bottom:5px;' onclick='seeUser("+userid+")' title='"+userlastname+" "+userfirstname+"' id='user_avatar_img' src='/{{ alias }}/uploads/avatar/"+useravatar+"' class='avatar'>";
|
||||
html+= userlastname+" "+userfirstname;
|
||||
html+= "</span>";
|
||||
$("#useronline").append(html);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user