mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 04:15:17 +00:00
Can send create post request on the API
This commit is contained in:
@ -445,8 +445,22 @@ ComunicWeb.components.posts.form = {
|
||||
var visibilityLevel = visibility_choices_contener.querySelector("input:checked").value;
|
||||
datas.append("visibility", visibilityLevel);
|
||||
|
||||
//Lock the send button
|
||||
sendButton.disabled = true;
|
||||
|
||||
//Try to perform the request
|
||||
|
||||
ComunicWeb.components.posts.interface.send_post(kind, id, datas, function(result){
|
||||
|
||||
//Check for errors
|
||||
if(result.error){
|
||||
ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to send a new post !", "danger");
|
||||
return;
|
||||
}
|
||||
|
||||
//Else
|
||||
//DEBUG - Temporary behaviour
|
||||
sendButton.disabled = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -25,4 +25,26 @@ ComunicWeb.components.posts.interface = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a new post
|
||||
*
|
||||
* @param {string} kind The kind of page
|
||||
* @param {string} id The ID of the kind of page
|
||||
* @param {FormData} data The data of the new post
|
||||
* @param {function} callback The function to call once the post is posted
|
||||
*/
|
||||
send_post: function(kind, id, data, callback){
|
||||
|
||||
//Prepare the request
|
||||
var apiURI = "posts/create";
|
||||
|
||||
//Append the kind of post to the request
|
||||
data.append("kind-page", kind);
|
||||
data.append("kind-id", id);
|
||||
|
||||
//Perform the request
|
||||
ComunicWeb.common.api.makeFormDatarequest(apiURI, data, true, callback);
|
||||
|
||||
},
|
||||
|
||||
}
|
Reference in New Issue
Block a user