Conversation update form : user automaticaly selected

This commit is contained in:
Pierre 2017-06-17 16:37:40 +02:00
parent 37b07b9676
commit 6408ab9b23
3 changed files with 47 additions and 0 deletions

View File

@ -33,6 +33,7 @@ function createElem(nodeType, appendTo){
* @info {HTMLElement} title The title of the new element
* @info {HTMLElement} src The src attribute of the new element
* @info {HTMLElement} type The type of the new element
* @info {HTMLElement} value The value of the new element
* @info {HTMLElement} innerHTML Specify the html content of the newly created element
* @return {HTMLElement} The newly created element
*/
@ -68,6 +69,10 @@ function createElem2(infos){
if(infos.type)
newElem.type = infos.type;
//Specify element value
if(infos.value)
newElem.value = infos.value;
//Specify node content
if(infos.innerHTML)
newElem.innerHTML = infos.innerHTML;

View File

@ -207,6 +207,7 @@ ComunicWeb.components.conversations.chatWindows = {
settingsForm.conversationNameInput.value = infos.infos.name;
//Update conversation members
ComunicWeb.components.userSelect.pushEntries(settingsForm.usersElement, infos.infos.members);
//Update follow conversation checkbox

View File

@ -100,5 +100,46 @@ ComunicWeb.components.userSelect = {
//Return result IDs
return usersID;
},
/**
* Push entries to user select element
*
* @param {HTMLElement} inputSelect The target element (select2 initialized)
* @param {array} usersID The ID of the users to push in select2 element
* @return {Boolean} True for a success
*/
pushEntries(inputSelect, usersID){
//Get informations about the entries
getMultipleUsersInfos(usersID, function(usersInfos){
//Check for errors
if(usersInfos.error){
//Log error
ComunicWeb.debug.logMessage("Error ! Couldn't fill select2 element because a request on the server failed !");
return false;
}
//In case of success
var i;
for(i in usersInfos){
//Create the new option
var option = createElem2({
type: "option",
value: usersInfos[i].userID,
innerHTML: usersInfos[i].firstName + " " + usersInfos[i].lastName,
});
option.setAttribute("selected", "true");
//Apply the new option
$(inputSelect).append(option);
$(inputSelect).trigger("change");
}
})
//Success
return true;
}
};