documentation for all JS files
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
/**
|
||||
* @fileoverview Manages room member management functionality.
|
||||
* This file handles:
|
||||
* - User selection interface using Select2
|
||||
* - Adding new members to a room
|
||||
* - Removing existing members
|
||||
* - Form submission with member data
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes member management functionality when the document is ready.
|
||||
* Sets up:
|
||||
* - Select2 dropdown for user selection
|
||||
* - Member removal functionality
|
||||
* - Member addition functionality
|
||||
* - Form submission handling
|
||||
* @function
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
// Initialize Select2 for user selection
|
||||
$('.select2').select2({
|
||||
@@ -5,13 +23,22 @@ $(document).ready(function() {
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
// Handle member removal
|
||||
/**
|
||||
* Handles member removal from the list.
|
||||
* Removes the member row from the UI when the remove button is clicked.
|
||||
* @event
|
||||
*/
|
||||
$(document).on('click', '.btn-remove-member', function() {
|
||||
const memberRow = $(this).closest('.member-row');
|
||||
memberRow.remove();
|
||||
});
|
||||
|
||||
// Handle adding new member
|
||||
/**
|
||||
* Handles adding a new member to the list.
|
||||
* Validates the selection and adds the member if not already present.
|
||||
* Creates a new member row with user details and adds it to the list.
|
||||
* @event
|
||||
*/
|
||||
$('#addMemberBtn').on('click', function() {
|
||||
const select = $('#user_id');
|
||||
const selectedOption = select.find('option:selected');
|
||||
@@ -52,7 +79,12 @@ $(document).ready(function() {
|
||||
select.val(null).trigger('change');
|
||||
});
|
||||
|
||||
// Handle form submission
|
||||
/**
|
||||
* Handles form submission.
|
||||
* Collects all member IDs and adds them as hidden inputs to the form.
|
||||
* @event
|
||||
* @param {Event} e - The form submission event
|
||||
*/
|
||||
$('#membersForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user