diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index 70cd9605..9e8b1f70 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -535,7 +535,7 @@ const ConvChatWindow = { }; //Create the conversation form - var settingsForm = ComunicWeb.components.conversations.utils.createConversationForm(settingsPane); + const settingsForm = ConversationsUtils.createConversationForm(settingsPane); //Update form informations settingsForm.createButton.innerHTML = "Update settings"; @@ -555,22 +555,19 @@ const ConvChatWindow = { //We hide conversation users (presents in members pane) settingsForm.usersElement.parentNode.style.display = "none"; + + settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove(); } //Update follow conversation checkbox status - if(conversation.infos.following == "1"){ - $(settingsForm.followConversationInput).iCheck("check"); - } - else { - $(settingsForm.followConversationInput).iCheck("uncheck"); - } + $(settingsForm.followConversationInput).iCheck(conversation.infos.following == "1" ? "check" : "uncheck"); //Save settings form in global form conversation.settingsForm = settingsForm; //Make update settings button lives - settingsForm.createButton.onclick = function(){ - ComunicWeb.components.conversations.chatWindows.submitUpdateForm(conversation); + settingsForm.createButton.onclick = () => { + this.submitUpdateForm(conversation); }; //Success @@ -633,13 +630,15 @@ const ConvChatWindow = { return false; } + newValues.canEveryoneAddMembers = conversation.settingsForm.allowEveryoneToAddMembers.checked; + } //Now, freeze the submit button conversation.settingsForm.createButton.disabled = true; //Peform a request through the interface - ComunicWeb.components.conversations.interface.updateSettings(newValues, function(result){ + ConversationsInterface.updateSettings(newValues, function(result){ //Enable again update button conversation.settingsForm.createButton.disabled = false; diff --git a/assets/js/components/conversations/interface.js b/assets/js/components/conversations/interface.js index 896a5a09..ffb92496 100644 --- a/assets/js/components/conversations/interface.js +++ b/assets/js/components/conversations/interface.js @@ -134,6 +134,9 @@ const ConversationsInterface = { if(infos.following !== undefined) params.following = infos.following; + if(infos.canEveryoneAddMembers !== undefined) + params.canEveryoneAddMembers = infos.canEveryoneAddMembers; + //Perform API request ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){ //Empty the cache (considered as deprecated) diff --git a/assets/js/components/conversations/utils.js b/assets/js/components/conversations/utils.js index 190d596c..2bdd846f 100644 --- a/assets/js/components/conversations/utils.js +++ b/assets/js/components/conversations/utils.js @@ -79,12 +79,12 @@ const ConversationsUtils = { * Create and display a conversation creation / edition form * * @param {HTMLElement} target The target of the creation form - * @return {Object} Informations about the form + * @return {ConversationSettingsFormElements} Information about the form */ createConversationForm: function(target){ //Create form object - var form = {}; + const form = {}; //Create and display conversation creation form form.rootElem = createElem("div", target); @@ -109,13 +109,21 @@ const ConversationsUtils = { placeholder: "Optionnal", type: "text"}); - //Follow disucssion + // Follow discussion form.followConversationInput = createFormGroup({ target: form.rootElem, label: "Follow conversation", checked: true, type: "checkbox"}); + // Allow all the members of the conversation to add other members + form.allowEveryoneToAddMembers = createFormGroup({ + target: form.rootElem, + type: "checkbox", + checked: true, + label: "Allow everyone to add members" + }); + //Create button form.createButton = createElem2({ type: "button", diff --git a/assets/js/typings/Conversations.d.ts b/assets/js/typings/Conversations.d.ts new file mode 100644 index 00000000..aecbf5b4 --- /dev/null +++ b/assets/js/typings/Conversations.d.ts @@ -0,0 +1,13 @@ +/** + * Conversations typings + * + * @author Pierre Hubert + */ + +declare interface ConversationSettingsFormElements { + rootElem: HTMLElement, + usersElement: HTMLElement, + conversationNameInput: HTMLElement, + allowEveryoneToAddMembers: HTMLElement, + followConversationInput: HTMLElement, +} \ No newline at end of file