mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Can request membership deletion on the server.
This commit is contained in:
parent
e805dda4fb
commit
c9d0a597f5
@ -22,6 +22,10 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-members-page .member div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.group-members-page .member .user-image {
|
.group-members-page .member .user-image {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
max-width: 50px;
|
max-width: 50px;
|
||||||
@ -31,4 +35,13 @@
|
|||||||
.group-members-page .member .member-name {
|
.group-members-page .member .member-name {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-members-page .member .delete-link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-members-page .member .delete-link:active {
|
||||||
|
color: #3c8dbc;
|
||||||
}
|
}
|
@ -173,5 +173,22 @@ ComunicWeb.components.groups.interface = {
|
|||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove (delete) a member from the group
|
||||||
|
*
|
||||||
|
* @param {Number} groupID The ID of the target group
|
||||||
|
* @param {Number} userID The ID of the target user
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
deleteMember: function(groupID, userID, callback){
|
||||||
|
//Perform the request over the API
|
||||||
|
var apiURI = "groups/delete_member";
|
||||||
|
var params = {
|
||||||
|
groupID: groupID,
|
||||||
|
userID: userID
|
||||||
|
};
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -153,10 +153,49 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
|
|
||||||
createElem2({
|
createElem2({
|
||||||
appendTo: memberContainer,
|
appendTo: memberContainer,
|
||||||
type: "span",
|
type: "div",
|
||||||
class: "member-name",
|
class: "member-name",
|
||||||
innerHTML: userFullName(userInfo)
|
innerHTML: userFullName(userInfo)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Add an option to delete the member
|
||||||
|
if(userID() != userInfo.userID){
|
||||||
|
|
||||||
|
//Delete user button
|
||||||
|
var deleteUserButton = createElem2({
|
||||||
|
appendTo: memberContainer,
|
||||||
|
type: "div",
|
||||||
|
class: "delete-link",
|
||||||
|
innerHTML: "<i class='fa fa-trash'></i>"
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteUserButton.addEventListener("click", function(e){
|
||||||
|
|
||||||
|
//Ask user confirmation
|
||||||
|
ComunicWeb.common.messages.confirm("Do you really want to delete this membership ?", function(r){
|
||||||
|
if(!r) return;
|
||||||
|
|
||||||
|
//Hide the member
|
||||||
|
memberContainer.style.visibility = "hidden";
|
||||||
|
|
||||||
|
ComunicWeb.components.groups.interface.deleteMember(info.id, userInfo.userID, function(result){
|
||||||
|
|
||||||
|
//Show the member
|
||||||
|
memberContainer.style.visibility = "visible";
|
||||||
|
|
||||||
|
//Check for error
|
||||||
|
if(result.error)
|
||||||
|
return notify("Could not delete the member from the group!", "danger");
|
||||||
|
|
||||||
|
//Else, remove completely the member
|
||||||
|
memberContainer.remove();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user