From bb14c3bb49f7bf6d041a73f781d8b226187dd9a7 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 7 Jun 2017 16:55:47 +0200 Subject: [PATCH] Progress on discussions creation form --- assets/js/common/functionsSchema.js | 2 +- assets/js/common/page.js | 14 +++++++---- assets/js/components/discussions/list.js | 30 +++++++++++++++++++++--- corePage/config/dev.config.php | 1 + 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 7118d478..f1f12976 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -138,7 +138,7 @@ var ComunicWeb = { /** * Show a transparent wait splash screen */ - showTransparentWaitSplashScreen: function(){}, + showTransparentWaitSplashScreen: function(target){}, /** * Open a page diff --git a/assets/js/common/page.js b/assets/js/common/page.js index 9bbfdea9..e3bf3c4f 100644 --- a/assets/js/common/page.js +++ b/assets/js/common/page.js @@ -69,20 +69,24 @@ ComunicWeb.common.page = { /** * Show a transparent wait splash screen * - * @returns {elem} The splash screen element to let it being deleted + * @param {HTMLElement} target Optionnal, defines the target of the transparent splashscreen + * @returns {HTMLElement} The splash screen element to let it being deleted */ - showTransparentWaitSplashScreen: function(){ + showTransparentWaitSplashScreen: function(target){ //Create the element - var waitSplashScreen = document.createElement("div"); + var waitSplashScreen = createElem("div"); waitSplashScreen.className = "transparentWaitSplashScreen"; //Populate it - var imgElem = document.createElement("img"); + var imgElem = createElem("img"); imgElem.src = ComunicWeb.__config.assetsURL+"img/barProgress.gif"; waitSplashScreen.appendChild(imgElem); //Apply splash screen - document.body.appendChild(waitSplashScreen); + if(!target) + document.body.appendChild(waitSplashScreen); + else + target.appendChild(waitSplashScreen); //Return wait splash screen element return waitSplashScreen; diff --git a/assets/js/components/discussions/list.js b/assets/js/components/discussions/list.js index d8b04bd9..b66599e3 100644 --- a/assets/js/components/discussions/list.js +++ b/assets/js/components/discussions/list.js @@ -104,7 +104,7 @@ ComunicWeb.components.discussions.list = { //Generate a summary object about all the informations we have got var infos = { listBox: listBox, - userElement: usersElement, + usersElement: usersElement, discussionNameInput: discussionNameInput, followDiscussionInput: followDiscussionInput, }; @@ -123,7 +123,7 @@ ComunicWeb.components.discussions.list = { * * @param {Object} infos Data to pass to the function * * @info {Object} listBox Informations about the listbox creating the discussion - * * @info {HTMLElement} userElement Pointer on userElement + * * @info {HTMLElement} usersElement Pointer on userElement * * @info {HTMLElement} discussionNameInput Pointer on the input of the form of the discussion * * @info {HTMLElement} followDiscussionInput Pointer on the "follow discussion" checkbox * @return {Boolean} True for a success @@ -131,6 +131,30 @@ ComunicWeb.components.discussions.list = { submitCreateDiscussionForm: function(infos){ //First, get the list of users - console.log("hello from list.js"); + var selectedUsers = ComunicWeb.components.userSelect.getResults(infos.usersElement); + + //We check if less than one user was selected + if(selectedUsers.length < 1){ + //Display an error notification + ComunicWeb.common.notificationSystem.showNotification("Please select at least one user!", "danger", 2); + + return false; + } + + //Add current user to the list + selectedUsers.push(ComunicWeb.user.userLogin.getUserID()); + + //Prepare the creation of the conversation + //Get all required informations + var discussionInformations = { + users: selectedUsers, + follow: infos.followDiscussionInput.checked, + discussionName: (infos.discussionNameInput.value == "" ? false : infos.discussionNameInput.value), + }; + + //Change box body style + var splashScreen = ComunicWeb.common.page.showTransparentWaitSplashScreen(infos.listBox.boxBody); + + //Contact the interface to create the conversation } } \ No newline at end of file diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index 4177f518..8c112772 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -81,6 +81,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/components/discussions/manager.js", "%PATH_ASSETS%js/components/discussions/list.js", "%PATH_ASSETS%js/components/discussions/windows.js", + "%PATH_ASSETS%js/components/discussions/interface.js", "%PATH_ASSETS%js/components/userSelect/userSelect.js", //User scripts