Can send create post request on the API

This commit is contained in:
Pierre
2018-01-06 15:26:43 +01:00
parent 1b5678cdd1
commit f7ba871344
3 changed files with 82 additions and 3 deletions

View File

@ -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;
});
}
},

View File

@ -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);
},
}