Progress on discussions creation form

This commit is contained in:
Pierre 2017-06-07 16:55:47 +02:00
parent 1f7a81aa12
commit bb14c3bb49
4 changed files with 38 additions and 9 deletions

View File

@ -138,7 +138,7 @@ var ComunicWeb = {
/** /**
* Show a transparent wait splash screen * Show a transparent wait splash screen
*/ */
showTransparentWaitSplashScreen: function(){}, showTransparentWaitSplashScreen: function(target){},
/** /**
* Open a page * Open a page

View File

@ -69,20 +69,24 @@ ComunicWeb.common.page = {
/** /**
* Show a transparent wait splash screen * 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 //Create the element
var waitSplashScreen = document.createElement("div"); var waitSplashScreen = createElem("div");
waitSplashScreen.className = "transparentWaitSplashScreen"; waitSplashScreen.className = "transparentWaitSplashScreen";
//Populate it //Populate it
var imgElem = document.createElement("img"); var imgElem = createElem("img");
imgElem.src = ComunicWeb.__config.assetsURL+"img/barProgress.gif"; imgElem.src = ComunicWeb.__config.assetsURL+"img/barProgress.gif";
waitSplashScreen.appendChild(imgElem); waitSplashScreen.appendChild(imgElem);
//Apply splash screen //Apply splash screen
document.body.appendChild(waitSplashScreen); if(!target)
document.body.appendChild(waitSplashScreen);
else
target.appendChild(waitSplashScreen);
//Return wait splash screen element //Return wait splash screen element
return waitSplashScreen; return waitSplashScreen;

View File

@ -104,7 +104,7 @@ ComunicWeb.components.discussions.list = {
//Generate a summary object about all the informations we have got //Generate a summary object about all the informations we have got
var infos = { var infos = {
listBox: listBox, listBox: listBox,
userElement: usersElement, usersElement: usersElement,
discussionNameInput: discussionNameInput, discussionNameInput: discussionNameInput,
followDiscussionInput: followDiscussionInput, followDiscussionInput: followDiscussionInput,
}; };
@ -123,7 +123,7 @@ ComunicWeb.components.discussions.list = {
* *
* @param {Object} infos Data to pass to the function * @param {Object} infos Data to pass to the function
* * @info {Object} listBox Informations about the listbox creating the discussion * * @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} discussionNameInput Pointer on the input of the form of the discussion
* * @info {HTMLElement} followDiscussionInput Pointer on the "follow discussion" checkbox * * @info {HTMLElement} followDiscussionInput Pointer on the "follow discussion" checkbox
* @return {Boolean} True for a success * @return {Boolean} True for a success
@ -131,6 +131,30 @@ ComunicWeb.components.discussions.list = {
submitCreateDiscussionForm: function(infos){ submitCreateDiscussionForm: function(infos){
//First, get the list of users //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
} }
} }

View File

@ -81,6 +81,7 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/components/discussions/manager.js", "%PATH_ASSETS%js/components/discussions/manager.js",
"%PATH_ASSETS%js/components/discussions/list.js", "%PATH_ASSETS%js/components/discussions/list.js",
"%PATH_ASSETS%js/components/discussions/windows.js", "%PATH_ASSETS%js/components/discussions/windows.js",
"%PATH_ASSETS%js/components/discussions/interface.js",
"%PATH_ASSETS%js/components/userSelect/userSelect.js", "%PATH_ASSETS%js/components/userSelect/userSelect.js",
//User scripts //User scripts