refactor(js): move multiSelect into batchToolbar + move residual method into relevant components

This commit is contained in:
Edouard Vanbelle
2026-05-26 22:59:43 +02:00
parent 1cd934d594
commit 6ac4e6177c
13 changed files with 215 additions and 81 deletions
@@ -1,14 +1,16 @@
/**
* OxiCloud - Multi-Select & Batch Actions Module
* OxiCloud — Batch Toolbar Module
*
* Adds checkboxes to grid and list views, replaces the list-view header
* with a NextCloud-style selection bar when items are selected, and
* provides batch delete / move / download / favorites operations.
* Manages the floating selection bar that appears when items are selected,
* and executes batch operations (delete, move, download, favorites).
*
* Selection state (_selected, handleToggleItem, selectAll, …) is kept here
* while the main file manager still uses its own delegation (ui.js).
* Once ui.js is migrated to ResourceListComponent (plan step B5), all
* selection mechanics will live in the component and this module will
* shrink to only the toolbar UI and batch-operation API calls.
*/
// TODO: rename into selection-bar ?
// TODO: merge with photo part
import { loadFiles } from '../../app/filesView.js';
import { app } from '../../app/state.js';
import { showConfirmDialog, ui } from '../../app/ui.js';
@@ -22,7 +24,7 @@ import { getAuthHeaders } from './fileOperations.js';
* @import {BatchResult} from './fileOperations.js'
*/
const multiSelect = {
const batchToolbar = {
/** @type {Map<String, LightItem>} items: Map<id, { id, name, type, parentId }> */
_selected: new Map(),
@@ -536,4 +538,4 @@ const multiSelect = {
}
};
export { multiSelect };
export { batchToolbar };
+9 -9
View File
@@ -18,7 +18,7 @@ import { musicView } from '../library/music.js';
import { fileSharing } from '../sharing/fileSharing.js';
import { fileOps } from './fileOperations.js';
import { inlineViewer } from './inlineViewer.js';
import { multiSelect } from './multiSelect.js';
import { batchToolbar } from './batchToolbar.js';
import { wopiEditor } from './wopiEditor.js';
/**
@@ -330,8 +330,8 @@ const contextMenus = {
// Copy button handler
copyConfirmBtn.addEventListener('click', async () => {
// Batch copy mode (from multiSelect)
if (app.moveDialogMode === 'batch' && multiSelect) {
// Batch copy mode (from batchToolbar)
if (app.moveDialogMode === 'batch' && batchToolbar) {
const targetId = app.selectedTargetFolderId;
const items = app.batchMoveItems || [];
@@ -341,10 +341,10 @@ const contextMenus = {
const result = await fileOps.batchCopy(fileIds, folderIds, targetId);
this.closeMoveDialog();
multiSelect.clear();
batchToolbar.clear();
loadFiles();
multiSelect.showBatchResult('copy', result);
batchToolbar.showBatchResult('copy', result);
return;
}
@@ -363,8 +363,8 @@ const contextMenus = {
});
moveConfirmBtn.addEventListener('click', async () => {
// Batch move mode (from multiSelect)
if (app.moveDialogMode === 'batch' && multiSelect) {
// Batch move mode (from batchToolbar)
if (app.moveDialogMode === 'batch' && batchToolbar) {
const targetId = app.selectedTargetFolderId;
const items = app.batchMoveItems || [];
@@ -374,9 +374,9 @@ const contextMenus = {
const result = await fileOps.batchMove(fileIds, folderIds, targetId);
this.closeMoveDialog();
multiSelect.clear();
batchToolbar.clear();
loadFiles();
multiSelect.showBatchResult('move', result);
batchToolbar.showBatchResult('move', result);
return;
}