Can update conversation message content.

This commit is contained in:
Pierre HUBERT 2019-01-11 18:17:37 +01:00
parent f8e8454b86
commit 584bb42c93
5 changed files with 105 additions and 1 deletions

View File

@ -810,7 +810,14 @@ var ComunicWeb = {
*/ */
unreadDropdown: { unreadDropdown: {
//TODO : implementd //TODO : implementd
} },
/**
* Conversation message editor
*/
messageEditor: {
//TODO : implement
},
}, },
/** /**

View File

@ -935,6 +935,33 @@ ComunicWeb.components.conversations.chatWindows = {
//Add message options //Add message options
if(userIsPoster){ 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 //Delete the message
var deleteLi = createElem2({ var deleteLi = createElem2({
type: "li", type: "li",

View File

@ -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 * Intend to delete a single conversation message
* *

View 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);
}
);
}
);
}
}

View File

@ -370,6 +370,7 @@ class Dev {
"js/components/conversations/cachingOpened.js", "js/components/conversations/cachingOpened.js",
"js/components/conversations/utils.js", "js/components/conversations/utils.js",
"js/components/conversations/unreadDropdown.js", "js/components/conversations/unreadDropdown.js",
"js/components/conversations/messageEditor.js",
//User selector //User selector
"js/components/userSelect/userSelect.js", "js/components/userSelect/userSelect.js",