Make a request on the server to delete comment.

This commit is contained in:
Pierre 2018-01-23 06:49:19 +01:00
parent 298d0b37d1
commit 2065cc03d7
2 changed files with 48 additions and 0 deletions

View File

@ -6,4 +6,23 @@
ComunicWeb.components.comments.interface = { ComunicWeb.components.comments.interface = {
/**
* Delete a comment
*
* @param {number} commentID The ID of the comment to delete
* @param {function} callback What to do once the comment has been delete
*/
delete: function(commentID, callback){
//Perform a request on the API
var apiURI = "comments/delete";
var params = {
commentID: commentID
};
//Make the request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
}
}; };

View File

@ -126,6 +126,35 @@ ComunicWeb.components.comments.ui = {
class: "fa fa-trash" class: "fa fa-trash"
}); });
//Make button lives
deleteCommentLink.onclick = function(){
ComunicWeb.common.messages.confirm("Are you sure do you want to delete this comment ? This operation is unrecoverable!", function(response){
//Check if user cancelled the operation
if(!response)
return;
//Hide the comment
commentContener.style.visibility = "hidden";
//Delete the comment
ComunicWeb.components.comments.interface.delete(infos.ID, function(response){
commentContener.style.visibility = "visible";
//Check for errors
if(response.error){
ComunicWeb.common.notificationSystem.showNotification("Could not delete comment!", "danger");
return;
}
});
});
}
} }
//Add comment content //Add comment content