documentation for all JS files
This commit is contained in:
@@ -1,4 +1,24 @@
|
||||
/**
|
||||
* @fileoverview Manages modal dialogs for the room interface.
|
||||
* This file handles:
|
||||
* - Modal initialization and configuration
|
||||
* - File operations (delete, rename, move)
|
||||
* - Folder creation
|
||||
* - File details display
|
||||
* - Overwrite confirmation
|
||||
* - Batch operations
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class ModalManager
|
||||
* @classdesc Manages all modal dialogs and their interactions in the room interface.
|
||||
* Handles file operations, folder creation, and various confirmation dialogs.
|
||||
*/
|
||||
export class ModalManager {
|
||||
/**
|
||||
* Creates a new ModalManager instance.
|
||||
* @param {RoomManager} roomManager - The parent RoomManager instance
|
||||
*/
|
||||
constructor(roomManager) {
|
||||
this.roomManager = roomManager;
|
||||
|
||||
@@ -16,6 +36,10 @@ export class ModalManager {
|
||||
this.initializeModals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes event listeners for all modals.
|
||||
* Sets up handlers for delete, new folder, rename, and move operations.
|
||||
*/
|
||||
initializeModals() {
|
||||
// Initialize delete modal
|
||||
if (this.roomManager.canDelete) {
|
||||
@@ -55,6 +79,11 @@ export class ModalManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the delete confirmation modal for a single file.
|
||||
* @param {string} filename - The name of the file to delete
|
||||
* @param {string} [path=''] - The path of the file to delete
|
||||
*/
|
||||
showDeleteModal(filename, path = '') {
|
||||
console.log('[ModalManager] Showing delete modal for:', { filename, path });
|
||||
const fileNameEl = document.getElementById('deleteFileName');
|
||||
@@ -82,6 +111,10 @@ export class ModalManager {
|
||||
this.deleteModal.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the delete confirmation modal for multiple selected files.
|
||||
* Processes all selected checkboxes and prepares for batch deletion.
|
||||
*/
|
||||
showBatchDeleteModal() {
|
||||
const selectedCheckboxes = document.querySelectorAll('.select-item-checkbox:checked');
|
||||
if (selectedCheckboxes.length === 0) return;
|
||||
@@ -130,6 +163,10 @@ export class ModalManager {
|
||||
this.deleteModal.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the rename modal for a file or folder.
|
||||
* @param {string} filename - The current name of the file/folder
|
||||
*/
|
||||
showRenameModal(filename) {
|
||||
document.getElementById('renameError').textContent = '';
|
||||
const ext = filename.includes('.') ? filename.substring(filename.lastIndexOf('.')) : '';
|
||||
@@ -149,6 +186,10 @@ export class ModalManager {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the file details modal.
|
||||
* @param {Object} file - The file object containing details to display
|
||||
*/
|
||||
showDetailsModal(file) {
|
||||
const icon = file.type === 'folder'
|
||||
? `<i class='fas fa-folder' style='font-size:2.2rem;color:var(--primary-color);'></i>`
|
||||
@@ -182,6 +223,11 @@ export class ModalManager {
|
||||
this.detailsModal.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the overwrite confirmation modal.
|
||||
* @param {string} filename - The name of the file that would be overwritten
|
||||
* @returns {Promise<string>} A promise that resolves with the user's choice ('skip', 'skip_all', 'overwrite', or 'overwrite_all')
|
||||
*/
|
||||
showOverwriteModal(filename) {
|
||||
return new Promise((resolve) => {
|
||||
const fileNameEl = document.getElementById('overwriteFileName');
|
||||
@@ -206,6 +252,11 @@ export class ModalManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the move file modal.
|
||||
* @param {string} fileId - The ID of the file to move
|
||||
* @param {string} path - The current path of the file
|
||||
*/
|
||||
showMoveModal(fileId, path) {
|
||||
console.log('[ModalManager] Showing move modal for file:', { fileId, path });
|
||||
document.getElementById('moveError').textContent = '';
|
||||
@@ -251,6 +302,10 @@ export class ModalManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new folder in the current path.
|
||||
* @async
|
||||
*/
|
||||
async createFolder() {
|
||||
const folderName = document.getElementById('folderNameInput').value.trim();
|
||||
if (!folderName) {
|
||||
@@ -290,6 +345,10 @@ export class ModalManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a file or folder.
|
||||
* @async
|
||||
*/
|
||||
async renameFile() {
|
||||
const newName = document.getElementById('renameInput').value.trim();
|
||||
if (!newName) {
|
||||
|
||||
Reference in New Issue
Block a user