From 28ce08883a00ba29db29a63caa4839a9c51cb5b4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 23 Dec 2017 14:52:01 +0100 Subject: [PATCH] Display user name on its page --- assets/js/common/functionsSchema.js | 7 +++ assets/js/pages/userPage/accessForbidden.js | 3 + assets/js/pages/userPage/main.js | 29 +++++++++- assets/js/pages/userPage/profileInfos.js | 63 +++++++++++++++++++++ corePage/config/dev.config.php | 1 + 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 assets/js/pages/userPage/profileInfos.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 6e5a7aca..b90b1480 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -710,6 +710,13 @@ var ComunicWeb = { }, + /** + * Display user profile informations + */ + profileInfos: { + //TODO : implement + } + }, /** diff --git a/assets/js/pages/userPage/accessForbidden.js b/assets/js/pages/userPage/accessForbidden.js index 997fb240..cf27aa66 100644 --- a/assets/js/pages/userPage/accessForbidden.js +++ b/assets/js/pages/userPage/accessForbidden.js @@ -70,6 +70,9 @@ ComunicWeb.pages.userPage.accessForbidden = { * @param {HTMLElement} target Target element for user informations */ showBasicInfos: function(userInfos, target){ + + //Update page title + document.title = userInfos.firstName + " " + userInfos.lastName; //Create box root var boxRoot = createElem2({ diff --git a/assets/js/pages/userPage/main.js b/assets/js/pages/userPage/main.js index 0056886f..966348e7 100644 --- a/assets/js/pages/userPage/main.js +++ b/assets/js/pages/userPage/main.js @@ -119,8 +119,33 @@ ComunicWeb.pages.userPage.main = { * @param {HTMLElement} target Target of the user page */ displayUserPage: function(infos, params, target){ - console.log("Display user page based on the informations we got"); - console.log(infos); + + //Update page title + document.title = infos.firstName + " " + infos.lastName; + + //Create the section class content + var sectionContent = createElem2({ + appendTo: target, + type: "section", + class: "content" + }); + + //Content row + var row = createElem2({ + appendTo: sectionContent, + type: "div", + class: "row" + }); + + //Create left column + var leftColumn = createElem2({ + appendTo: row, + type: "div", + class: "col-md-3" + }); + + //Display profile informations + ComunicWeb.pages.userPage.profileInfos.display(infos, leftColumn); } } \ No newline at end of file diff --git a/assets/js/pages/userPage/profileInfos.js b/assets/js/pages/userPage/profileInfos.js new file mode 100644 index 00000000..c0ef156b --- /dev/null +++ b/assets/js/pages/userPage/profileInfos.js @@ -0,0 +1,63 @@ +/** + * Profile informations displaying handler + * + * Handlers the rendering of informations such as + * the name of the user, or account informations + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.userPage.profileInfos = { + + /** + * Display profile informations + * + * @param {Object} infos Informations about the user + * @param {HTMLElement} target The target of the profile informations + */ + display: function(infos, target){ + + //Create the main box + this.createMainBox(infos, target); + + }, + + /** + * Display the main informations about the user + * + * @param {Object} infos Informations about the user + * @param {HTMLElement} target The target of the box + */ + createMainBox: function(infos, target){ + + //Create box contener + var boxContener = createElem2({ + appendTo: target, + type: "div", + class: "box box-primary" + }); + + //Setup box body + var boxBody = createElem2({ + appendTo: boxContener, + type: "div", + class: "box-body box-profile" + }); + + //Add user image + var userImage = createElem2({ + appendTo: boxBody, + type: "img", + class: "profile-user-img img-responsive img-circle", + src: infos.accountImage + }); + + //Add user name + var userName = createElem2({ + appendTo: boxBody, + type: "h3", + class: "profile-username text-center", + innerHTML: infos.firstName + " " + infos.lastName + }); + } +}; \ No newline at end of file diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index bd81ccdd..12a9a30b 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -176,6 +176,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/pages/userPage/main.js", "%PATH_ASSETS%js/pages/userPage/accessForbidden.js", "%PATH_ASSETS%js/pages/userPage/friendshipStatus.js", + "%PATH_ASSETS%js/pages/userPage/profileInfos.js", //Login page "%PATH_ASSETS%js/pages/login.js",