mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can cancel groups membership invitations.
This commit is contained in:
parent
d541506820
commit
1d88b8ea69
@ -225,5 +225,22 @@ ComunicWeb.components.groups.interface = {
|
||||
accept: accept
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancel a membership invitation
|
||||
*
|
||||
* @param {Number} groupID The ID of the target group
|
||||
* @param {Number} userID The ID of the target user
|
||||
* @param {Function} callback
|
||||
*/
|
||||
cancelInvitation: function(groupID, userID, callback){
|
||||
//Perform the request over the API
|
||||
var apiURI = "groups/cancel_invitation";
|
||||
var params = {
|
||||
groupID: groupID,
|
||||
userID: userID
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
};
|
@ -238,7 +238,7 @@ ComunicWeb.pages.groups.pages.members = {
|
||||
if(member.level == "pending"){
|
||||
|
||||
//Disable membership level button
|
||||
membershipLevelButton.style.display = true;
|
||||
membershipLevelButton.disabled = true;
|
||||
|
||||
//Create container
|
||||
var responseContainer = createElem2({
|
||||
@ -304,5 +304,39 @@ ComunicWeb.pages.groups.pages.members = {
|
||||
rejectRequest.addEventListener("click", function(e){respondRequest(false)});
|
||||
}
|
||||
|
||||
//Check if the user was invited
|
||||
else if(member.level == "invited"){
|
||||
|
||||
//Disable membership level button
|
||||
membershipLevelButton.disabled = true;
|
||||
|
||||
//Add a button to cancel invitation
|
||||
var cancelInvitationButton = createElem2({
|
||||
appendTo: memberContainer,
|
||||
type: "div",
|
||||
class: "btn btn-danger",
|
||||
innerHTML: "Cancel"
|
||||
});
|
||||
|
||||
cancelInvitationButton.addEventListener("click", function(e){
|
||||
|
||||
//Peform the request on the APi
|
||||
ComunicWeb.components.groups.interface.cancelInvitation(info.id, userInfo.userID, function(result){
|
||||
|
||||
cancelInvitationButton.style.visibility = "hidden";
|
||||
|
||||
//Check for errors
|
||||
if(result.error){
|
||||
cancelInvitationButton.style.visibility = "visible";
|
||||
return notify("An error occurred while trying to cancel the invitation!", "danger");
|
||||
}
|
||||
|
||||
//Remove the member
|
||||
memberContainer.remove();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user