refactor(js): move multiSelect into batchToolbar + move residual method into relevant components
This commit is contained in:
@@ -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 };
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { ui } from '../../app/ui.js';
|
||||
import { getCsrfHeaders } from '../../core/csrf.js';
|
||||
import { i18n } from '../../core/i18n.js';
|
||||
import { multiSelect } from '../files/multiSelect.js';
|
||||
import { batchToolbar } from '../files/batchToolbar.js';
|
||||
import * as pathTooltip from '../pathTooltip.js';
|
||||
|
||||
/** @import {FavoriteItem, FileItem, FolderItem} from '../../core/types.js' */
|
||||
@@ -181,7 +181,7 @@ const favorites = {
|
||||
ui.resetFilesList(); // ensure also list visible & error hidden
|
||||
// wire buttons & select-all-checkbox as list header has changed in ui.resetFilesList()
|
||||
// FIXME: this case is not easy to understand, should apply better implementation
|
||||
multiSelect.init();
|
||||
batchToolbar.init();
|
||||
|
||||
ui.updateBreadcrumb();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { ui } from '../../app/ui.js';
|
||||
import { getCsrfHeaders } from '../../core/csrf.js';
|
||||
import { i18n } from '../../core/i18n.js';
|
||||
import { multiSelect } from '../files/multiSelect.js';
|
||||
import { batchToolbar } from '../files/batchToolbar.js';
|
||||
import * as pathTooltip from '../pathTooltip.js';
|
||||
|
||||
/** @import {FileItem, FolderItem, ItemTypeEnum, RecentItem} from '../../core/types.js' */
|
||||
@@ -111,9 +111,9 @@ const recent = {
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (multiSelect) {
|
||||
multiSelect.clear();
|
||||
multiSelect.init(); // this will wire buttons & select-all-checkbox
|
||||
if (batchToolbar) {
|
||||
batchToolbar.clear();
|
||||
batchToolbar.init(); // this will wire buttons & select-all-checkbox
|
||||
}
|
||||
ui.updateBreadcrumb();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user