mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Make a request on the server to delete comment.
This commit is contained in:
parent
298d0b37d1
commit
2065cc03d7
@ -6,4 +6,23 @@
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
};
|
@ -126,6 +126,35 @@ ComunicWeb.components.comments.ui = {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user