mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Can delete conversation messages
This commit is contained in:
parent
41354be949
commit
f8e8454b86
@ -115,4 +115,8 @@
|
|||||||
|
|
||||||
#conversationsElem .direct-chat-msg.not-last-message-from-user .direct-chat-img {
|
#conversationsElem .direct-chat-msg.not-last-message-from-user .direct-chat-img {
|
||||||
margin-bottom: -5px;
|
margin-bottom: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#conversationsElem .direct-chat-msg.open .dropdown-menu {
|
||||||
|
margin-top: -20px;
|
||||||
}
|
}
|
@ -910,6 +910,68 @@ ComunicWeb.components.conversations.chatWindows = {
|
|||||||
element: textMessage,
|
element: textMessage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Add message dropdown menu
|
||||||
|
messageContainer.className += " dropdown";
|
||||||
|
|
||||||
|
var dropdownToggle = createElem2({
|
||||||
|
insertBefore: dateElem,
|
||||||
|
type: "i",
|
||||||
|
class: "hidden"
|
||||||
|
});
|
||||||
|
dropdownToggle.setAttribute("data-toggle", "dropdown");
|
||||||
|
|
||||||
|
var dropdownMenu = createElem2({
|
||||||
|
insertBefore: dateElem,
|
||||||
|
type: "ul",
|
||||||
|
class: "dropdown-menu"
|
||||||
|
});
|
||||||
|
dropdownMenu.setAttribute("role", "menu");
|
||||||
|
|
||||||
|
messageTargetElem.addEventListener("dblclick", function(){
|
||||||
|
$(dropdownToggle).dropdown("toggle");
|
||||||
|
});
|
||||||
|
|
||||||
|
//Add message options
|
||||||
|
if(userIsPoster){
|
||||||
|
|
||||||
|
//Delete the message
|
||||||
|
var deleteLi = createElem2({
|
||||||
|
type: "li",
|
||||||
|
appendTo: dropdownMenu
|
||||||
|
});
|
||||||
|
|
||||||
|
var deleteLink = createElem2({
|
||||||
|
type: "a",
|
||||||
|
appendTo: deleteLi,
|
||||||
|
innerHTML: "Delete"
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteLink.addEventListener("click", function(){
|
||||||
|
ComunicWeb.common.messages.confirm(
|
||||||
|
"Do you really want to delete this message? The operation can not be reverted!",
|
||||||
|
function(confirm){
|
||||||
|
if(!confirm) return;
|
||||||
|
|
||||||
|
//Hide the message
|
||||||
|
messageTargetElem.style.display = "none";
|
||||||
|
|
||||||
|
//Execute the request
|
||||||
|
ComunicWeb.components.conversations.interface.DeleteSingleMessage(
|
||||||
|
message.ID,
|
||||||
|
function(result){
|
||||||
|
if(!result){
|
||||||
|
messageTargetElem.style.display = "block";
|
||||||
|
notify("Could delete conversation message!", "danger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//Return information about the message
|
//Return information about the message
|
||||||
return {
|
return {
|
||||||
userID: message.ID_user,
|
userID: message.ID_user,
|
||||||
|
@ -363,6 +363,27 @@ ComunicWeb.components.conversations.interface = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intend to delete a single conversation message
|
||||||
|
*
|
||||||
|
* @param {Number} messageID The ID of the message to delete
|
||||||
|
* @param {(success: Boolean) => any} callback Function to call once the
|
||||||
|
* conversation message has been deleted
|
||||||
|
*/
|
||||||
|
DeleteSingleMessage: function(messageID, callback){
|
||||||
|
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(
|
||||||
|
"conversations/deleteMessage",
|
||||||
|
{"messageID": messageID},
|
||||||
|
true,
|
||||||
|
|
||||||
|
function(result){
|
||||||
|
callback(result.error ? false : true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty conversations cache
|
* Empty conversations cache
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user