mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can delete groups.
This commit is contained in:
		@@ -36,3 +36,12 @@
 | 
				
			|||||||
    margin-bottom: 10px;
 | 
					    margin-bottom: 10px;
 | 
				
			||||||
    display: block;
 | 
					    display: block;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.group-settings-container .delete-group-link-container {
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					    padding: 20px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.group-settings-container .delete-group-link-container a {
 | 
				
			||||||
 | 
					    color: black;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -337,5 +337,22 @@ ComunicWeb.components.groups.interface = {
 | 
				
			|||||||
			follow: follow
 | 
								follow: follow
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
 | 
							ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Delete a group
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {Number} groupID The ID of the group to delete
 | 
				
			||||||
 | 
						 * @param {String} password The password of the user, for security
 | 
				
			||||||
 | 
						 * @param {Function} callback
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						deleteGroup: function(groupID, password, callback){
 | 
				
			||||||
 | 
							//Perform the request over the API
 | 
				
			||||||
 | 
							var apiURI = "groups/delete";
 | 
				
			||||||
 | 
							var params = {
 | 
				
			||||||
 | 
								groupID: groupID,
 | 
				
			||||||
 | 
								password: password
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -523,5 +523,56 @@ ComunicWeb.pages.groups.pages.settings = {
 | 
				
			|||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/**
 | 
				
			||||||
 | 
							 * Delete group link
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							var deleteLinkContainer = createElem2({
 | 
				
			||||||
 | 
								appendTo: formContainer,
 | 
				
			||||||
 | 
								type: "div",
 | 
				
			||||||
 | 
								class: "delete-group-link-container",
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var deleteLink = createElem2({
 | 
				
			||||||
 | 
								appendTo: deleteLinkContainer,
 | 
				
			||||||
 | 
								type: "a",
 | 
				
			||||||
 | 
								innerHTML: "Delete the group"
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							deleteLink.addEventListener("click", function(){
 | 
				
			||||||
 | 
								ComunicWeb.pages.groups.pages.settings.confirm_delete_group(id);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Confirm groups deletion
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {number} groupID Target group ID
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						confirm_delete_group: function(groupID){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ComunicWeb.common.messages.confirm("Do you really want to delete this group? The operation can not be reverted!", function(r){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(!r) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								ComunicWeb.common.messages.promptPassword({callback: function(password){
 | 
				
			||||||
 | 
									if(!password) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									ComunicWeb.components.groups.interface.deleteGroup(groupID, password, function(result){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if(result.error)
 | 
				
			||||||
 | 
											return notify("Could not delete the group! (maybe your password was incorrect...)", "danger");
 | 
				
			||||||
 | 
										
 | 
				
			||||||
 | 
										notify("The group was successfully deleted!", "success");
 | 
				
			||||||
 | 
										openPage("groups");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
 | 
								}});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user