mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-02 00:26:26 +00:00
Send a request on server to delete a post
This commit is contained in:
parent
dc160e558a
commit
f675d2ae03
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -183,6 +183,27 @@ ComunicWeb.components.posts.ui = {
|
|||||||
innerHTML: "<i class='fa fa-trash'></i>"
|
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)
|
//Add post attachement (if any)
|
||||||
|
Loading…
Reference in New Issue
Block a user