mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Reorganized groups member page.
This commit is contained in:
parent
ccd0fd03a9
commit
413cc6ddf8
@ -15,7 +15,7 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
open: function(id, target){
|
open: function(id, target){
|
||||||
|
|
||||||
//Create container
|
//Create container
|
||||||
var membersContainer = createElem2({
|
var membersPage = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "col-md-6 group-members-page"
|
class: "col-md-6 group-members-page"
|
||||||
@ -23,7 +23,7 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
|
|
||||||
//Add backward link
|
//Add backward link
|
||||||
var backwardLink = createElem2({
|
var backwardLink = createElem2({
|
||||||
appendTo: membersContainer,
|
appendTo: membersPage,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "a backward-link",
|
class: "a backward-link",
|
||||||
innerHTML: "<i class='fa fa-arrow-left'></i> Go back to the group"
|
innerHTML: "<i class='fa fa-arrow-left'></i> Go back to the group"
|
||||||
@ -32,21 +32,12 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
openPage("groups/" + id);
|
openPage("groups/" + id);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Loading message
|
|
||||||
var loadingMsg = ComunicWeb.common.messages.createCalloutElem(
|
|
||||||
"Loading",
|
|
||||||
"Please wait while we load a few information...",
|
|
||||||
"info"
|
|
||||||
);
|
|
||||||
membersContainer.appendChild(loadingMsg);
|
|
||||||
|
|
||||||
//Get information about the group
|
//Get information about the group
|
||||||
ComunicWeb.components.groups.interface.getInfo(id, function(info){
|
ComunicWeb.components.groups.interface.getInfo(id, function(info){
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(info.error){
|
if(info.error){
|
||||||
loadingMsg.remove();
|
membersPage.appendChild(
|
||||||
membersContainer.appendChild(
|
|
||||||
ComunicWeb.common.messages.createCalloutElem(
|
ComunicWeb.common.messages.createCalloutElem(
|
||||||
"Error",
|
"Error",
|
||||||
"Could not get group information !",
|
"Could not get group information !",
|
||||||
@ -56,13 +47,63 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComunicWeb.pages.groups.pages.members.applyGroupInfo(id, info, membersPage);
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply group information
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the group
|
||||||
|
* @param {Object} info Information about the target of the group
|
||||||
|
* @param {HTMLElement} target The target for the page
|
||||||
|
*/
|
||||||
|
applyGroupInfo: function(id, info, target){
|
||||||
|
|
||||||
|
document.title = info.name + " - Members";
|
||||||
|
|
||||||
|
//Append the title of the group
|
||||||
|
createElem2({
|
||||||
|
appendTo: target,
|
||||||
|
type: "h2",
|
||||||
|
class: "title",
|
||||||
|
innerHTML: "Members of " + info.name
|
||||||
|
});
|
||||||
|
|
||||||
|
//Refresh the list of members of the group
|
||||||
|
var membersList = createElem2({
|
||||||
|
appendTo: target,
|
||||||
|
type: "div",
|
||||||
|
class: "members-list"
|
||||||
|
});
|
||||||
|
ComunicWeb.pages.groups.pages.members.refreshMembersList(id, info, membersList);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the list of members of the group
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the target group
|
||||||
|
* @param {Object} info Information about the group
|
||||||
|
* @param {HTMLElement} target The target for the list
|
||||||
|
*/
|
||||||
|
refreshMembersList: function(id, info, target){
|
||||||
|
|
||||||
|
//Loading message
|
||||||
|
var loadingMsg = ComunicWeb.common.messages.createCalloutElem(
|
||||||
|
"Loading",
|
||||||
|
"Please wait while we load a few information...",
|
||||||
|
"info"
|
||||||
|
);
|
||||||
|
target.appendChild(loadingMsg);
|
||||||
|
|
||||||
//Get the list of members of the group
|
//Get the list of members of the group
|
||||||
ComunicWeb.components.groups.interface.getMembers(id, function(members){
|
ComunicWeb.components.groups.interface.getMembers(id, function(members){
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(members.error){
|
if(members.error){
|
||||||
loadingMsg.remove();
|
loadingMsg.remove();
|
||||||
membersContainer.appendChild(
|
target.appendChild(
|
||||||
ComunicWeb.common.messages.createCalloutElem(
|
ComunicWeb.common.messages.createCalloutElem(
|
||||||
"Error",
|
"Error",
|
||||||
"Could not get group members !",
|
"Could not get group members !",
|
||||||
@ -76,12 +117,12 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
var membersIDs = ComunicWeb.components.groups.utils.getMembersIDs(members);
|
var membersIDs = ComunicWeb.components.groups.utils.getMembersIDs(members);
|
||||||
|
|
||||||
//Get information about the members of the group
|
//Get information about the members of the group
|
||||||
ComunicWeb.user.userInfos.getMultipleUsersInfos(membersIDs, function(users){
|
getMultipleUsersInfos(membersIDs, function(users){
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if(users.error){
|
if(users.error){
|
||||||
loadingMsg.remove();
|
loadingMsg.remove();
|
||||||
membersContainer.appendChild(
|
target.appendChild(
|
||||||
ComunicWeb.common.messages.createCalloutElem(
|
ComunicWeb.common.messages.createCalloutElem(
|
||||||
"Error",
|
"Error",
|
||||||
"Could not get group members information !",
|
"Could not get group members information !",
|
||||||
@ -94,15 +135,11 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
//Remove loading message
|
//Remove loading message
|
||||||
loadingMsg.remove();
|
loadingMsg.remove();
|
||||||
|
|
||||||
//Display the members list
|
//Display the group members list
|
||||||
ComunicWeb.pages.groups.pages.members.displayList(info, members, users, membersContainer);
|
ComunicWeb.pages.groups.pages.members.displayList(info, members, users, target);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -115,27 +152,9 @@ ComunicWeb.pages.groups.pages.members = {
|
|||||||
* @param {HTMLElement} target The target for the list
|
* @param {HTMLElement} target The target for the list
|
||||||
*/
|
*/
|
||||||
displayList: function(info, list, users, target){
|
displayList: function(info, list, users, target){
|
||||||
|
|
||||||
document.title = info.name + " - Members";
|
|
||||||
|
|
||||||
//Append the title of the group
|
|
||||||
createElem2({
|
|
||||||
appendTo: target,
|
|
||||||
type: "h2",
|
|
||||||
class: "title",
|
|
||||||
innerHTML: "Members of " + info.name
|
|
||||||
});
|
|
||||||
|
|
||||||
//Process the list of the members
|
|
||||||
var membersList = createElem2({
|
|
||||||
appendTo: target,
|
|
||||||
type: "div",
|
|
||||||
class: "members-list"
|
|
||||||
});
|
|
||||||
|
|
||||||
//Process the list of members
|
//Process the list of members
|
||||||
list.forEach(function(member){
|
list.forEach(function(member){
|
||||||
ComunicWeb.pages.groups.pages.members._display_member(info, member, users, membersList);
|
ComunicWeb.pages.groups.pages.members._display_member(info, member, users, target);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user