Send a request on server to delete a post

This commit is contained in:
Pierre 2018-01-11 06:59:30 +01:00
parent dc160e558a
commit f675d2ae03
2 changed files with 40 additions and 0 deletions

View File

@ -68,4 +68,23 @@ ComunicWeb.components.posts.interface = {
},
/**
* Delete a post
*
* @param {int} postID The ID of the post to delete
* @param {function} callback What to do once we got a reponse
*/
delete: function(postID, callback){
//Prepare an API request
apiURI = "posts/delete";
params = {
postID: postID
};
//Perform the request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
}
}

View File

@ -183,6 +183,27 @@ ComunicWeb.components.posts.ui = {
innerHTML: "<i class='fa fa-trash'></i>"
});
//Make delete button lives
deleteButtonLink.onclick = function(){
//Create a confirmation dialog
ComunicWeb.common.messages.confirm("Are you sure do you want to delete this post? The operation can not be reverted !", function(accept){
//Check if the user cancelled the operation
if(!accept)
return;
postRoot.style.visibility = "hidden";
//Delete the post
ComunicWeb.components.posts.interface.delete(infos.ID, function(response){
postRoot.style.visibility = "visible";
});
});
}
}
//Add post attachement (if any)