diff --git a/assets/css/pages/groups/pages/members.css b/assets/css/pages/groups/pages/members.css index 5911bd15..4e666d8a 100644 --- a/assets/css/pages/groups/pages/members.css +++ b/assets/css/pages/groups/pages/members.css @@ -22,6 +22,10 @@ margin-bottom: 10px; } +.group-members-page .member div { + display: inline-block; +} + .group-members-page .member .user-image { border-radius: 50%; max-width: 50px; @@ -31,4 +35,13 @@ .group-members-page .member .member-name { margin-left: 5px; font-weight: bold; + width: 150px; +} + +.group-members-page .member .delete-link { + cursor: pointer; +} + +.group-members-page .member .delete-link:active { + color: #3c8dbc; } \ No newline at end of file diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index e0719af0..bb033531 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -173,5 +173,22 @@ ComunicWeb.components.groups.interface = { id: id }; 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); } }; \ No newline at end of file diff --git a/assets/js/pages/groups/pages/members.js b/assets/js/pages/groups/pages/members.js index 9306cbe9..73f073e6 100644 --- a/assets/js/pages/groups/pages/members.js +++ b/assets/js/pages/groups/pages/members.js @@ -153,10 +153,49 @@ ComunicWeb.pages.groups.pages.members = { createElem2({ appendTo: memberContainer, - type: "span", + type: "div", class: "member-name", 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: "" + }); + + 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(); + + }); + + }); + + }) + } }); } } \ No newline at end of file