Can accept a reject a friendship request

This commit is contained in:
Pierre 2017-12-21 19:09:53 +01:00
parent fb88265727
commit fe71d9839c
2 changed files with 42 additions and 3 deletions

View File

@ -78,7 +78,7 @@ ComunicWeb.components.friends.list = {
"friendID": friendID,
};
if(accept)
if(accept == true)
params.accept = "true";
else
params.accept = "false";

View File

@ -32,7 +32,7 @@ ComunicWeb.pages.userPage.friendshipStatus = {
if(response.received_request){
//Offer the user to reject a frienship request
createElem2({
var rejectRequest = createElem2({
appendTo: target,
type: "button",
class: "btn btn-xs btn-danger",
@ -46,13 +46,52 @@ ComunicWeb.pages.userPage.friendshipStatus = {
})
//Offer the user to accept a frienship request
createElem2({
var acceptRequest = createElem2({
appendTo: target,
type: "button",
class: "btn btn-xs btn-success",
innerHTML: "Accept request"
});
//Prepare the buttons
acceptRequest.setAttribute("data-accept", "true");
rejectRequest.setAttribute("data-accept", "false");
//Setup the action
var respondRequest = function(){
//Lock the buttons
acceptRequest.disabled = true;
rejectRequest.disabled = true;
//Get the status of the request
var accept = this.getAttribute("data-accept") == "true";
//Perform the action
ComunicWeb.components.friends.list.respondRequest(userID, accept, function(response){
//Unlock the buttons
acceptRequest.disabled = false;
rejectRequest.disabled = false;
//Check for errors
if(response.error){
ComunicWeb.common.notificationSystem.showNotification("Couldn't update request status !",
"danger", 5);
}
else {
//Reopen user page
openUserPage(userID);
}
});
}
acceptRequest.onclick = respondRequest;
rejectRequest.onclick = respondRequest;
}
//Check if user has sent a friendship request