mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Can accept a reject a friendship request
This commit is contained in:
parent
fb88265727
commit
fe71d9839c
@ -78,7 +78,7 @@ ComunicWeb.components.friends.list = {
|
|||||||
"friendID": friendID,
|
"friendID": friendID,
|
||||||
};
|
};
|
||||||
|
|
||||||
if(accept)
|
if(accept == true)
|
||||||
params.accept = "true";
|
params.accept = "true";
|
||||||
else
|
else
|
||||||
params.accept = "false";
|
params.accept = "false";
|
||||||
|
@ -32,7 +32,7 @@ ComunicWeb.pages.userPage.friendshipStatus = {
|
|||||||
if(response.received_request){
|
if(response.received_request){
|
||||||
|
|
||||||
//Offer the user to reject a frienship request
|
//Offer the user to reject a frienship request
|
||||||
createElem2({
|
var rejectRequest = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "button",
|
type: "button",
|
||||||
class: "btn btn-xs btn-danger",
|
class: "btn btn-xs btn-danger",
|
||||||
@ -46,13 +46,52 @@ ComunicWeb.pages.userPage.friendshipStatus = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//Offer the user to accept a frienship request
|
//Offer the user to accept a frienship request
|
||||||
createElem2({
|
var acceptRequest = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "button",
|
type: "button",
|
||||||
class: "btn btn-xs btn-success",
|
class: "btn btn-xs btn-success",
|
||||||
innerHTML: "Accept request"
|
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
|
//Check if user has sent a friendship request
|
||||||
|
Loading…
Reference in New Issue
Block a user