2017-02-18 17:26:30 +00:00
|
|
|
/**
|
|
|
|
* Common homes functions
|
2017-02-18 17:37:36 +00:00
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
2017-02-18 17:26:30 +00:00
|
|
|
*/
|
|
|
|
ComunicWeb.pages.home.home = {
|
|
|
|
/**
|
|
|
|
* Open home page
|
2017-02-18 17:37:36 +00:00
|
|
|
*
|
2017-02-18 17:26:30 +00:00
|
|
|
* @param {Object} additionnalData Additionnal data passed in the method
|
|
|
|
* @param {element} targetElement Where the template will be applied
|
|
|
|
* @returns {Boolean} False if it fails
|
|
|
|
*/
|
|
|
|
openHomePage: function(additionnalData, targetElement){
|
|
|
|
//Check wether if user is logged in or not
|
|
|
|
var userLoggedIn = ComunicWeb.user.userLogin.getUserLoginState();
|
|
|
|
|
2017-05-22 16:12:50 +00:00
|
|
|
//Check if user is in or not
|
2017-02-18 17:26:30 +00:00
|
|
|
if(userLoggedIn){
|
2017-05-22 16:12:50 +00:00
|
|
|
//Dev feature : Show result
|
2017-02-18 17:26:30 +00:00
|
|
|
targetElement.appendChild(ComunicWeb.common.messages.createCalloutElem("", "User logged in !", "info"));
|
2017-03-01 14:37:55 +00:00
|
|
|
|
|
|
|
//Create logout button
|
|
|
|
var loginButton = document.createElement("button");
|
|
|
|
loginButton.onclick = (function(){
|
|
|
|
ComunicWeb.common.page.openPage("logout");
|
|
|
|
});
|
|
|
|
loginButton.innerHTML="Logout";
|
|
|
|
targetElement.appendChild(loginButton);
|
2017-06-05 14:03:14 +00:00
|
|
|
|
|
|
|
//Create select user element
|
|
|
|
var formGroup = createElem("div", targetElement);
|
|
|
|
formGroup.className = "form-group";
|
|
|
|
var selectElement = createElem("select", formGroup);
|
|
|
|
selectElement.className = "form-control select2";
|
|
|
|
selectElement.setAttribute("multiple", "multiple");
|
|
|
|
selectElement.setAttribute("data-placeholder", "Select users");
|
|
|
|
|
|
|
|
//Initialize user selector
|
|
|
|
ComunicWeb.components.userSelect.init(selectElement);
|
|
|
|
|
2017-02-18 17:26:30 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-05-22 16:12:50 +00:00
|
|
|
//Display landing page
|
|
|
|
ComunicWeb.pages.home.landingPage.display(targetElement);
|
2017-02-18 17:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Everything seems to be OK
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|