mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Created conversation creation form
This commit is contained in:
parent
dea79bdce1
commit
ba5273eafe
@ -69,52 +69,19 @@ ComunicWeb.components.conversations.list = {
|
||||
//Change box title
|
||||
listBox.boxTitle.innerHTML = "New conversation";
|
||||
|
||||
//Create and display conversation creation form
|
||||
var createForm = createElem("div", listBox.boxBody);
|
||||
|
||||
//Choose users
|
||||
//Create select user element
|
||||
var usersElement = createFormGroup({
|
||||
target: createForm,
|
||||
label: "Users",
|
||||
multiple: true,
|
||||
placeholder: "Select users",
|
||||
type: "select2"});
|
||||
|
||||
//Initialize user selector
|
||||
ComunicWeb.components.userSelect.init(usersElement);
|
||||
|
||||
|
||||
//Conversation name
|
||||
var conversationNameInput = createFormGroup({
|
||||
target: createForm,
|
||||
label: "Conversation name",
|
||||
placeholder: "Optionnal",
|
||||
type: "text"});
|
||||
|
||||
//Follow disucssion
|
||||
var followConversationInput = createFormGroup({
|
||||
target: createForm,
|
||||
label: "Follow conversation",
|
||||
checked: true,
|
||||
type: "checkbox"});
|
||||
|
||||
//Create button
|
||||
var createButton = createElem("button", createForm);
|
||||
createButton.className = "btn btn-primary";
|
||||
createButton.style.width = "100%";
|
||||
createButton.innerHTML = "Create conversation";
|
||||
//Create the form
|
||||
var form = ComunicWeb.components.conversations.utils.createConversationForm(listBox.boxBody);
|
||||
|
||||
//Generate a summary object about all the informations we have got
|
||||
var infos = {
|
||||
listBox: listBox,
|
||||
usersElement: usersElement,
|
||||
conversationNameInput: conversationNameInput,
|
||||
followConversationInput: followConversationInput,
|
||||
usersElement: form.usersElement,
|
||||
conversationNameInput: form.conversationNameInput,
|
||||
followConversationInput: form.followConversationInput,
|
||||
};
|
||||
|
||||
//Make button lives
|
||||
createButton.onclick = function(){
|
||||
form.createButton.onclick = function(){
|
||||
ComunicWeb.components.conversations.list.submitCreateConversationForm(infos);
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,59 @@ ComunicWeb.components.conversations.utils = {
|
||||
|
||||
//Success
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create and display a conversation creation / edition form
|
||||
*
|
||||
* @param {HTMLElement} target The target of the creation form
|
||||
* @return {Object} Informations about the form
|
||||
*/
|
||||
createConversationForm: function(target){
|
||||
|
||||
//Create form object
|
||||
var form = {};
|
||||
|
||||
//Create and display conversation creation form
|
||||
form.rootElem = createElem("div", target);
|
||||
|
||||
//Choose users
|
||||
//Create select user element
|
||||
form.usersElement = createFormGroup({
|
||||
target: form.rootElem,
|
||||
label: "Users",
|
||||
multiple: true,
|
||||
placeholder: "Select users",
|
||||
type: "select2"});
|
||||
|
||||
//Initialize user selector
|
||||
ComunicWeb.components.userSelect.init(form.usersElement);
|
||||
|
||||
|
||||
//Conversation name
|
||||
form.conversationNameInput = createFormGroup({
|
||||
target: form.rootElem,
|
||||
label: "Conversation name",
|
||||
placeholder: "Optionnal",
|
||||
type: "text"});
|
||||
|
||||
//Follow disucssion
|
||||
form.followConversationInput = createFormGroup({
|
||||
target: form.rootElem,
|
||||
label: "Follow conversation",
|
||||
checked: true,
|
||||
type: "checkbox"});
|
||||
|
||||
//Create button
|
||||
form.createButton = createElem2({
|
||||
type: "button",
|
||||
appendTo: form.rootElem,
|
||||
class: "btn btn-primary",
|
||||
innerHTML: "Create conversation"
|
||||
});
|
||||
form.createButton.style.width = "100%";
|
||||
|
||||
//Return result
|
||||
return form;
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue
Block a user