Multiple folder move added

This commit is contained in:
kodi
2026-03-11 16:27:21 +01:00
parent 3e4761f5a7
commit 6e7b3cffae
14 changed files with 428 additions and 43 deletions
+27 -2
View File
@@ -283,6 +283,10 @@ function isNestedPath(sourcePath, destinationPath) {
return destination.startsWith(`${source}/`);
}
function uniqueRootKeysForItems(items) {
return [...new Set(items.map((item) => rootKeyFromPath(item.path)).filter(Boolean))];
}
function renderBreadcrumbs(pane, path) {
const nav = document.getElementById(`${pane}-breadcrumbs`);
nav.innerHTML = "";
@@ -699,7 +703,22 @@ async function executeMoveSelection(baseDestination) {
if (selectedItems.length === 0) {
return;
}
const allFiles = selectedItems.every((item) => item.kind === "file");
setError("actions-error", "");
if (!allFiles) {
const result = await apiRequest("POST", "/api/files/move", {
sources: selectedItems.map((item) => item.path),
destination_base: baseDestination,
});
state.selectedTaskId = result.task_id;
await refreshTasksSnapshot();
setSelectedItem(sourcePane, null);
await Promise.all([loadBrowsePane("left"), loadBrowsePane("right")]);
setStatus("Move: batch started");
return;
}
let successes = 0;
let failures = 0;
let firstError = null;
@@ -995,8 +1014,14 @@ function openF6Flow() {
return openRenameMovePopup();
}
if (selectedItems.some((item) => item.kind !== "file")) {
showBatchDirectoryMoveNotSupported();
return true;
const roots = uniqueRootKeysForItems(selectedItems);
if (roots.length > 1) {
const message = "Batch move requires all selected items to be in the same root";
setError("actions-error", message);
setStatus(message);
return true;
}
return openBatchMovePopup(selectedItems);
}
return openBatchMovePopup(selectedItems);
}