Add delete actions

This commit is contained in:
Mikei386
2026-06-23 20:18:49 +02:00
parent 522b9f4665
commit 59cdfd975f
8 changed files with 44 additions and 4 deletions
+22
View File
@@ -272,6 +272,7 @@ function renderExplorer(body, win) {
<button class="icon" data-action="refresh" title="Neu laden" aria-label="Neu laden">↻</button>
<button class="icon" data-action="upload-files" title="Dateien hochladen" aria-label="Dateien hochladen" ${isReadOnly() ? 'disabled' : ''}>⤴</button>
<button class="icon" data-action="upload-folder" title="Ordner hochladen" aria-label="Ordner hochladen" ${isReadOnly() ? 'disabled' : ''}>⇪</button>
<button class="icon danger" data-action="delete-selected" title="Auswahl löschen" aria-label="Auswahl löschen" ${isReadOnly() ? 'disabled' : ''}>×</button>
<input class="upload-input" data-upload="files" type="file" multiple>
<input class="upload-input" data-upload="folder" type="file" multiple webkitdirectory directory>
<div class="view-toggle" aria-label="Ansicht">
@@ -293,6 +294,7 @@ function renderExplorer(body, win) {
body.querySelector('[data-action="view-icons"]').addEventListener('click', () => setExplorerView(win, 'icons'));
body.querySelector('[data-action="upload-files"]').addEventListener('click', () => body.querySelector('[data-upload="files"]').click());
body.querySelector('[data-action="upload-folder"]').addEventListener('click', () => body.querySelector('[data-upload="folder"]').click());
body.querySelector('[data-action="delete-selected"]').addEventListener('click', () => deleteEntries(win));
for (const inputEl of body.querySelectorAll('.upload-input')) {
inputEl.addEventListener('change', async () => {
try {
@@ -1042,6 +1044,25 @@ async function promptTransfer(win, entry, type) {
await createJob(type, entry.path, `${targetDir.replace(/\/$/, '')}/${entry.name}`, []);
}
async function deleteEntries(win, entry = null) {
if (isReadOnly()) {
showError(new Error('Read-only mode ist aktiv.'));
return;
}
const entries = entry && selectedPathSet(win).has(entry.path) ? selectedEntries(win) : (entry ? [entry] : selectedEntries(win));
if (!entries.length) {
showError(new Error('Keine Datei ausgewählt.'));
return;
}
const label = entries.length === 1 ? `"${entries[0].name}" wirklich löschen?` : `${entries.length} Objekte wirklich löschen?`;
if (!confirm(`${label}\n\nDieser Vorgang löscht direkt vom Dateisystem.`)) {
return;
}
for (const item of entries) {
await createJob('delete', item.path, null, [win.id]);
}
}
function openPermissionsDialog(win, entry) {
if (isReadOnly()) {
showError(new Error('Read-only mode ist aktiv.'));
@@ -1301,6 +1322,7 @@ function renderContextMenu() {
actions.push(['Berechtigungen...', () => openPermissionsDialog(win, entry)]);
actions.push(['Kopieren nach...', () => promptTransfer(win, entry, 'copy')]);
actions.push(['Verschieben nach...', () => promptTransfer(win, entry, 'move')]);
actions.push(['Löschen', () => deleteEntries(win, entry)]);
}
} else {
actions.push(['Aktuellen Ordner herunterladen', () => downloadEntries(win, null)]);
+8
View File
@@ -57,6 +57,14 @@
color: #ffffff;
}
.u-nav button.danger {
color: #c4382d;
}
.u-nav button.danger:hover {
border-color: #c4382d;
}
.u-nav button.icon {
align-items: center;
display: inline-flex;