mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Add new canEveryoneAddMembers setting
This commit is contained in:
		@@ -535,7 +535,7 @@ const ConvChatWindow = {
 | 
				
			|||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Create the conversation form
 | 
							//Create the conversation form
 | 
				
			||||||
		var settingsForm = ComunicWeb.components.conversations.utils.createConversationForm(settingsPane);
 | 
							const settingsForm = ConversationsUtils.createConversationForm(settingsPane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Update form informations
 | 
							//Update form informations
 | 
				
			||||||
		settingsForm.createButton.innerHTML = "Update settings";
 | 
							settingsForm.createButton.innerHTML = "Update settings";
 | 
				
			||||||
@@ -555,22 +555,19 @@ const ConvChatWindow = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			//We hide conversation users (presents in members pane)
 | 
								//We hide conversation users (presents in members pane)
 | 
				
			||||||
			settingsForm.usersElement.parentNode.style.display = "none";
 | 
								settingsForm.usersElement.parentNode.style.display = "none";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Update follow conversation checkbox status
 | 
							//Update follow conversation checkbox status
 | 
				
			||||||
		if(conversation.infos.following == "1"){
 | 
							$(settingsForm.followConversationInput).iCheck(conversation.infos.following == "1" ? "check" : "uncheck");
 | 
				
			||||||
			$(settingsForm.followConversationInput).iCheck("check");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			$(settingsForm.followConversationInput).iCheck("uncheck");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Save settings form in global form
 | 
							//Save settings form in global form
 | 
				
			||||||
		conversation.settingsForm = settingsForm;
 | 
							conversation.settingsForm = settingsForm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Make update settings button lives
 | 
							//Make update settings button lives
 | 
				
			||||||
		settingsForm.createButton.onclick = function(){
 | 
							settingsForm.createButton.onclick = () => {
 | 
				
			||||||
			ComunicWeb.components.conversations.chatWindows.submitUpdateForm(conversation);
 | 
								this.submitUpdateForm(conversation);
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Success
 | 
							//Success
 | 
				
			||||||
@@ -633,13 +630,15 @@ const ConvChatWindow = {
 | 
				
			|||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								newValues.canEveryoneAddMembers = conversation.settingsForm.allowEveryoneToAddMembers.checked;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Now, freeze the submit button
 | 
							//Now, freeze the submit button
 | 
				
			||||||
		conversation.settingsForm.createButton.disabled = true;
 | 
							conversation.settingsForm.createButton.disabled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Peform a request through the interface
 | 
							//Peform a request through the interface
 | 
				
			||||||
		ComunicWeb.components.conversations.interface.updateSettings(newValues, function(result){
 | 
							ConversationsInterface.updateSettings(newValues, function(result){
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			//Enable again update button
 | 
								//Enable again update button
 | 
				
			||||||
			conversation.settingsForm.createButton.disabled = false;
 | 
								conversation.settingsForm.createButton.disabled = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,9 @@ const ConversationsInterface = {
 | 
				
			|||||||
		if(infos.following !== undefined)
 | 
							if(infos.following !== undefined)
 | 
				
			||||||
			params.following = infos.following;
 | 
								params.following = infos.following;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(infos.canEveryoneAddMembers !== undefined)
 | 
				
			||||||
 | 
								params.canEveryoneAddMembers = infos.canEveryoneAddMembers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Perform API request
 | 
							//Perform API request
 | 
				
			||||||
		ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
 | 
							ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
 | 
				
			||||||
			//Empty the cache (considered as deprecated)
 | 
								//Empty the cache (considered as deprecated)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,12 +79,12 @@ const ConversationsUtils = {
 | 
				
			|||||||
	 * Create and display a conversation creation / edition form
 | 
						 * Create and display a conversation creation / edition form
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
	 * @param {HTMLElement} target The target of the creation 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){
 | 
						createConversationForm: function(target){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Create form object
 | 
							//Create form object
 | 
				
			||||||
		var form = {};
 | 
							const form = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Create and display conversation creation form
 | 
							//Create and display conversation creation form
 | 
				
			||||||
		form.rootElem = createElem("div", target);
 | 
							form.rootElem = createElem("div", target);
 | 
				
			||||||
@@ -109,13 +109,21 @@ const ConversationsUtils = {
 | 
				
			|||||||
			placeholder: "Optionnal", 
 | 
								placeholder: "Optionnal", 
 | 
				
			||||||
			type: "text"});
 | 
								type: "text"});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Follow disucssion
 | 
							// Follow discussion
 | 
				
			||||||
		form.followConversationInput = createFormGroup({
 | 
							form.followConversationInput = createFormGroup({
 | 
				
			||||||
			target: form.rootElem, 
 | 
								target: form.rootElem, 
 | 
				
			||||||
			label: "Follow conversation", 
 | 
								label: "Follow conversation", 
 | 
				
			||||||
			checked: true,
 | 
								checked: true,
 | 
				
			||||||
			type: "checkbox"});
 | 
								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
 | 
							//Create button
 | 
				
			||||||
		form.createButton = createElem2({
 | 
							form.createButton = createElem2({
 | 
				
			||||||
			type: "button", 
 | 
								type: "button", 
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								assets/js/typings/Conversations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								assets/js/typings/Conversations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Conversations typings
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author Pierre Hubert
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					declare interface ConversationSettingsFormElements {
 | 
				
			||||||
 | 
						rootElem: HTMLElement,
 | 
				
			||||||
 | 
						usersElement: HTMLElement,
 | 
				
			||||||
 | 
						conversationNameInput: HTMLElement,
 | 
				
			||||||
 | 
						allowEveryoneToAddMembers: HTMLElement,
 | 
				
			||||||
 | 
						followConversationInput: HTMLElement,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user