mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can update conversation message content.
This commit is contained in:
parent
f8e8454b86
commit
584bb42c93
@ -810,7 +810,14 @@ var ComunicWeb = {
|
||||
*/
|
||||
unreadDropdown: {
|
||||
//TODO : implementd
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Conversation message editor
|
||||
*/
|
||||
messageEditor: {
|
||||
//TODO : implement
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -935,6 +935,33 @@ ComunicWeb.components.conversations.chatWindows = {
|
||||
//Add message options
|
||||
if(userIsPoster){
|
||||
|
||||
//Update message content
|
||||
var updateLi = createElem2({
|
||||
type: "li",
|
||||
appendTo: dropdownMenu
|
||||
});
|
||||
|
||||
var updateLink = createElem2({
|
||||
type: "a",
|
||||
appendTo: updateLi,
|
||||
innerHTML: "Edit"
|
||||
});
|
||||
|
||||
updateLink.addEventListener("click", function(){
|
||||
ComunicWeb.components.conversations.messageEditor.open(message, function(newContent){
|
||||
|
||||
//Apply and parse new message
|
||||
textMessage.innerHTML = removeHtmlTags(newContent);
|
||||
ComunicWeb.components.textParser.parse({
|
||||
element: textMessage,
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//Delete the message
|
||||
var deleteLi = createElem2({
|
||||
type: "li",
|
||||
|
@ -363,6 +363,29 @@ ComunicWeb.components.conversations.interface = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Intend to update the content of a single message
|
||||
*
|
||||
* @param {Number} messageID The ID of the message to update
|
||||
* @param {String} content New content for the message
|
||||
* @param {(success : Boolean) => any} callback Function called when
|
||||
* the request is terminated
|
||||
*/
|
||||
UpdateSingleMessage: function(messageID, content, callback){
|
||||
ComunicWeb.common.api.makeAPIrequest(
|
||||
"conversations/updateMessage",
|
||||
{
|
||||
"messageID": messageID,
|
||||
"content": content
|
||||
},
|
||||
true,
|
||||
|
||||
function(result){
|
||||
callback(result.error ? false : true);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Intend to delete a single conversation message
|
||||
*
|
||||
|
46
assets/js/components/conversations/messageEditor.js
Normal file
46
assets/js/components/conversations/messageEditor.js
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Conversation message editor
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.components.conversations.messageEditor = {
|
||||
|
||||
/**
|
||||
* Open conversation message editor
|
||||
*
|
||||
* @param {Object} message Information about the message to open
|
||||
* @param {(newcontent : String) => any} callback Callback function called only
|
||||
* when the new message content has been applied
|
||||
*/
|
||||
open: function(message, callback){
|
||||
|
||||
ComunicWeb.common.messages.inputString(
|
||||
"Update message content",
|
||||
"Please specify the new content of the message:",
|
||||
message.message,
|
||||
|
||||
function(content){
|
||||
|
||||
//Intend to update message content
|
||||
ComunicWeb.components.conversations.interface.UpdateSingleMessage(
|
||||
message.ID,
|
||||
content,
|
||||
|
||||
function(result){
|
||||
|
||||
if(!result)
|
||||
return notify("Could not update conversation message content!", "danger");
|
||||
|
||||
message.message = content;
|
||||
callback(content);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -370,6 +370,7 @@ class Dev {
|
||||
"js/components/conversations/cachingOpened.js",
|
||||
"js/components/conversations/utils.js",
|
||||
"js/components/conversations/unreadDropdown.js",
|
||||
"js/components/conversations/messageEditor.js",
|
||||
|
||||
//User selector
|
||||
"js/components/userSelect/userSelect.js",
|
||||
|
Loading…
Reference in New Issue
Block a user