From 7cd434806655edfea1c0027a555f9c51e4776cae Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 10 Dec 2017 08:13:22 +0100 Subject: [PATCH] Ready to prepare user page implementation --- assets/js/common/functionsSchema.js | 19 +++++++++++++ assets/js/common/page.js | 16 +++++++++++ assets/js/pages/home/home.js | 44 ++--------------------------- assets/js/pages/userPage/main.js | 24 ++++++++++++++++ assets/js/pagesList.js | 9 ++++++ corePage/config/dev.config.php | 3 ++ 6 files changed, 73 insertions(+), 42 deletions(-) create mode 100644 assets/js/pages/userPage/main.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index a5c3032f..8c686420 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -643,6 +643,25 @@ var ComunicWeb = { } }, + /** + * User page + */ + userPage: { + + /** + * Main user page + */ + main: { + + /** + * Open user page + */ + open: function(params, target){}, + + }, + + }, + /** * Login controller */ diff --git a/assets/js/common/page.js b/assets/js/common/page.js index e63e8392..c479f07f 100644 --- a/assets/js/common/page.js +++ b/assets/js/common/page.js @@ -123,7 +123,18 @@ ComunicWeb.common.page = { //Check if there is also subfolders if(firstPartURI.indexOf("/") != -1){ + + //Save the list of subfolders + var subfoldersURIarray = firstPartURI.split("/"); + subfoldersURIarray.shift(); + subfoldersURI = subfoldersURIarray.join("/"); + + //Remove them to find the right page firstPartURI = firstPartURI.split("/")[0]; + + } else { + //No subfolder was specified + subfoldersURI = false; } //Check if specied page exists @@ -202,6 +213,11 @@ ComunicWeb.common.page = { //Check if some additionnal data was specified if(!additionnalData) additionnalData = {}; + + //Add the subfolder URI (if any) + if(subfoldersURI){ + additionnalData.subfolder = subfoldersURI; + } //Call the method related to the page eval(pageInfos.methodHandler + ("(additionnalData, pageTarget);")); diff --git a/assets/js/pages/home/home.js b/assets/js/pages/home/home.js index 259ce4fe..02b096cc 100644 --- a/assets/js/pages/home/home.js +++ b/assets/js/pages/home/home.js @@ -17,50 +17,10 @@ ComunicWeb.pages.home.home = { //Check if user is in or not if(userLoggedIn){ - //Dev feature : Show result - targetElement.appendChild(ComunicWeb.common.messages.createCalloutElem("", "User logged in !", "info")); - //Create logout button - var loginButton = document.createElement("button"); - loginButton.onclick = (function(){ - ComunicWeb.common.page.openPage("logout"); - }); - loginButton.innerHTML="Logout"; - targetElement.appendChild(loginButton); + //Open current user page + openPage("user/me"); - - - //Dev feature emojies - var emojiesArea = createElem2({ - appendTo: targetElement, - type: "p", - innerHTML: "Emoji test : :) 🇬🇫 🎅🏻 :( (movie) (cool)" - }); - - - //Parse emojies - ComunicWeb.components.emoji.parser.parse({ - element: emojiesArea, - }); - - //Create textarea element - var textarea = createFormGroup({ - target: targetElement, - type: "textarea", - label: "Textarea", - placeholder: "New message", - }); - textarea.style.width = "200px"; - - //Initializate textarea - var textarea2 = new ComunicWeb.components.textarea(); - textarea2.init({ - element: textarea, - minHeight: "32px", - maxHeight: "70px", - }); - - } else{ //Display landing page diff --git a/assets/js/pages/userPage/main.js b/assets/js/pages/userPage/main.js new file mode 100644 index 00000000..95e4ee79 --- /dev/null +++ b/assets/js/pages/userPage/main.js @@ -0,0 +1,24 @@ +/** + * User page + * + * Display the profile of the user + * + * Main file + * + * @author Pierre HUBERT + */ +ComunicWeb.pages.userPage.main = { + + /** + * Open user page + * + * @param {Object} params Parametres required to open the page + * @param {HTMLElement} target The target for the user page + */ + open: function(params, target){ + + console.log(params); + + } + +} \ No newline at end of file diff --git a/assets/js/pagesList.js b/assets/js/pagesList.js index fa3d6d96..ce57a18b 100644 --- a/assets/js/pagesList.js +++ b/assets/js/pagesList.js @@ -14,6 +14,15 @@ ComunicWeb.pagesList = { disableMenus: false, }, + /** + * User profile page + */ + user: { + pageTitle: "User Page", + methodHandler: "ComunicWeb.pages.userPage.main.open", + disableMenus: false, + }, + /** * Login page */ diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index 76717a79..1a999551 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -168,6 +168,9 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/pages/home/home.js", "%PATH_ASSETS%js/pages/home/landingPage.js", + //User page + "%PATH_ASSETS%js/pages/userPage/main.js", + //Login page "%PATH_ASSETS%js/pages/login.js",