Can cancel groups membership invitations.

This commit is contained in:
Pierre HUBERT 2018-07-09 15:57:51 +02:00
parent d541506820
commit 1d88b8ea69
2 changed files with 53 additions and 2 deletions

View File

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

View File

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