ComunicWeb/assets/js/pages/groups/sections/header.js
2021-03-15 18:04:20 +01:00

104 lines
2.6 KiB
JavaScript

/**
* Groups header
*
* @author Pierre HUBERT
*/
const GroupSectionHeader = {
/**
* 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 page row
var pageRow = createElem2({
appendTo: target,
type: "div",
class: "row group-page"
});
//Create header column
var headerColumn = createElem2({
appendTo: pageRow,
type: "div",
class: "col-md-6"
});
//Create header container
const headerContainer = createElem2({
appendTo: headerColumn,
type: "div",
class: "group-header box box-primary"
});
//Create a row
const row = createElem2({
appendTo: headerContainer,
type: "div",
class: "box-body row"
});
//First column
const firstColumn = createElem2({
appendTo: row,
type: "div",
class: "col-md-4 group-col-icon",
});
//Group icon
const groupIcon = createElem2({
appendTo: firstColumn,
type: "img",
src: info.icon_url,
class: "group-icon"
});
//Group name
const groupName = createElem2({
appendTo: firstColumn,
type: "span",
class: "group-name",
innerHTML: info.name
});
//Group tag (if any)
if(info.virtual_directory != "null"){
createElem2({
appendTo: firstColumn,
type: "small",
class: "group-tag",
innerHTML: "@" + info.virtual_directory
});
}
createElem2({
appendTo: row,
type: "div",
class: "spacer"
})
// Second column : basic information about the group
var thirdColumn = createElem2({
appendTo: row,
type: "div",
class: "col-md-7 col-metadata"
});
//Display membership level
ComunicWeb.pages.groups.sections.membershipBlock.display(info, thirdColumn);
//Display follow block
if(signed_in() && ComunicWeb.components.groups.utils.isGroupMember(info))
ComunicWeb.pages.groups.sections.followBlock.display(info, thirdColumn);
},
};
ComunicWeb.pages.groups.sections.header = GroupSectionHeader;