2018-07-03 09:45:57 +00:00
|
|
|
/**
|
|
|
|
* Groups header
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
ComunicWeb.pages.groups.sections.header = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display groups page header
|
|
|
|
*
|
|
|
|
* @param {Object} info Information about the group to display
|
|
|
|
* @param {HTMLElement} target The target for the header
|
|
|
|
*/
|
|
|
|
display: function(info, target){
|
|
|
|
|
|
|
|
//Create header container
|
|
|
|
var headerContainer = createElem2({
|
|
|
|
appendTo: target,
|
|
|
|
type: "div",
|
|
|
|
class: "group-header"
|
|
|
|
});
|
|
|
|
|
|
|
|
//Create a row
|
|
|
|
var row = createElem2({
|
|
|
|
appendTo: headerContainer,
|
|
|
|
type: "div",
|
|
|
|
class: "row"
|
|
|
|
});
|
|
|
|
|
|
|
|
//First column
|
|
|
|
var firstColumn = createElem2({
|
|
|
|
appendTo: row,
|
|
|
|
type: "div",
|
2018-07-07 05:27:55 +00:00
|
|
|
class: "col-md-4 group-col-icon",
|
2018-07-03 09:45:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
//Group icon
|
|
|
|
var groupIcon = createElem2({
|
|
|
|
appendTo: firstColumn,
|
|
|
|
type: "img",
|
|
|
|
src: info.icon_url,
|
|
|
|
class: "group-icon"
|
|
|
|
});
|
|
|
|
|
|
|
|
//Group name
|
|
|
|
var groupName = createElem2({
|
|
|
|
appendTo: firstColumn,
|
|
|
|
type: "span",
|
|
|
|
class: "group-name",
|
|
|
|
innerHTML: info.name
|
|
|
|
});
|
2018-07-03 11:06:55 +00:00
|
|
|
|
2018-07-15 16:37:10 +00:00
|
|
|
//Group tag (if any)
|
|
|
|
if(info.virtual_directory != "null"){
|
|
|
|
createElem2({
|
|
|
|
appendTo: firstColumn,
|
|
|
|
type: "small",
|
|
|
|
class: "group-tag",
|
|
|
|
innerHTML: "@" + info.virtual_directory
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-07 05:27:55 +00:00
|
|
|
|
|
|
|
//Second column : Information about the company
|
2018-07-03 11:06:55 +00:00
|
|
|
var secondColumn = createElem2({
|
|
|
|
appendTo: row,
|
|
|
|
type: "div",
|
2018-07-16 06:27:31 +00:00
|
|
|
class: "col-md-4 col-info"
|
2018-07-07 05:27:55 +00:00
|
|
|
});
|
|
|
|
|
2018-07-16 06:27:31 +00:00
|
|
|
//Group URL (if any)
|
|
|
|
if(info.url != "null"){
|
|
|
|
var urlElem = createElem2({
|
|
|
|
appendTo: secondColumn,
|
|
|
|
type: "a",
|
|
|
|
class: "a",
|
|
|
|
href: info.url,
|
|
|
|
innerHTML: "<i class='fa fa-link'></i> " + info.url
|
|
|
|
});
|
|
|
|
urlElem.target = "_blank";
|
2018-07-07 05:27:55 +00:00
|
|
|
|
2018-07-16 06:27:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Group description (if any)
|
|
|
|
if(info.url != "null")
|
|
|
|
createElem2({
|
|
|
|
appendTo: secondColumn,
|
|
|
|
type: "div",
|
|
|
|
innerHTML: "<i class='fa fa-file-text-o'></i> " + info.description
|
|
|
|
});
|
2018-07-15 16:37:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-07 05:27:55 +00:00
|
|
|
//Third column : information about the group
|
|
|
|
var thirdColumn = createElem2({
|
|
|
|
appendTo: row,
|
|
|
|
type: "div",
|
2018-07-16 06:27:31 +00:00
|
|
|
class: "col-md-4 col-metadata"
|
2018-07-03 11:06:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
//Add join date
|
2018-07-07 13:27:27 +00:00
|
|
|
createElem2({
|
2018-07-07 05:27:55 +00:00
|
|
|
appendTo: thirdColumn,
|
2018-07-03 11:06:55 +00:00
|
|
|
type: "div",
|
2018-07-04 12:21:58 +00:00
|
|
|
innerHTML: '<i class="fa fa-clock-o"></i> Created '+ComunicWeb.common.date.timeDiffToStr(info.time_create)+' ago'
|
2018-07-03 11:06:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
//Add number of members
|
2018-07-07 13:27:27 +00:00
|
|
|
var members = createElem2({
|
2018-07-07 05:27:55 +00:00
|
|
|
appendTo: thirdColumn,
|
2018-07-03 11:06:55 +00:00
|
|
|
type: "div",
|
|
|
|
innerHTML: '<i class="fa fa-group"></i> '+ info.number_members+' members'
|
|
|
|
});
|
2018-07-04 04:05:14 +00:00
|
|
|
|
2018-07-07 13:27:27 +00:00
|
|
|
//Check if the user is a moderator or an admin
|
|
|
|
if(info.membership == "administrator" || info.membership == "moderator"){
|
|
|
|
|
|
|
|
//Turn members information into a link
|
|
|
|
members.className = "a";
|
|
|
|
|
|
|
|
members.addEventListener("click", function(e){
|
|
|
|
|
|
|
|
openPage("groups/" + info.id + "/members");
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-07 05:36:03 +00:00
|
|
|
//Group visibility
|
|
|
|
var visibility = {
|
|
|
|
open: "Open group",
|
|
|
|
private: "Private group",
|
|
|
|
secrete: "Secrete group"
|
|
|
|
};
|
|
|
|
createElem2({
|
|
|
|
appendTo: thirdColumn,
|
|
|
|
type: "div",
|
|
|
|
innerHTML: "<i class='fa fa-lock'></i> " + visibility[info.visibility]
|
|
|
|
});
|
|
|
|
|
|
|
|
//Group registration
|
|
|
|
var levels = {
|
|
|
|
open: "Open registration",
|
|
|
|
moderated: "Moderated registration",
|
|
|
|
closed: "Closed registration"
|
|
|
|
}
|
|
|
|
createElem2({
|
|
|
|
appendTo: thirdColumn,
|
|
|
|
type: "div",
|
|
|
|
innerHTML: "<i class='fa fa-pencil'></i> " + levels[info.registration_level]
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-07-05 06:38:52 +00:00
|
|
|
//Display membership level
|
|
|
|
if(signed_in())
|
2018-07-07 05:27:55 +00:00
|
|
|
ComunicWeb.pages.groups.sections.membershipBlock.display(info, thirdColumn);
|
2018-07-05 06:38:52 +00:00
|
|
|
|
2018-07-04 04:05:14 +00:00
|
|
|
//If the user is an admin, add a link to configure the page
|
|
|
|
if(signed_in() && info.membership == "administrator"){
|
|
|
|
|
|
|
|
var settingsLink = createElem2({
|
2018-07-07 05:27:55 +00:00
|
|
|
appendTo: thirdColumn,
|
2018-07-04 04:05:14 +00:00
|
|
|
type: "div",
|
|
|
|
class: "a",
|
|
|
|
innerHTML: " <i class='fa fa-gear'></i>Settings"
|
|
|
|
});
|
|
|
|
settingsLink.addEventListener("click", function(e){
|
|
|
|
openPage("groups/" + info.id + "/settings");
|
|
|
|
});
|
|
|
|
}
|
2018-07-03 09:45:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
};
|