mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 01:48:50 +00:00
Conversation update form : user automaticaly selected
This commit is contained in:
parent
37b07b9676
commit
6408ab9b23
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user