Show partial folder selections

This commit is contained in:
Mikei386
2026-06-15 20:15:35 +02:00
parent 9249fad65a
commit 68c5d677e6
8 changed files with 29 additions and 9 deletions
+8 -1
View File
@@ -448,10 +448,17 @@
const host = document.getElementById('bu-source-browser');
if (!host) return;
const selected = new Set(state.backupSelections);
const rows = state.sourceDirectories.map(item => `<tr><td><input type="checkbox" class="bu-source-select" value="${esc(item.path)}" ${selected.has(item.path)?'checked':''}></td><td>Ordner</td><td>${esc(item.name)}</td><td>${esc(item.path)}</td><td>${button('Öffnen',`open-source-dir:${encodeURIComponent(item.path)}`)}</td></tr>`).join('');
const rows = state.sourceDirectories.map(item => {
const exact=selected.has(item.path);
const prefix=item.path.replace(/\/$/,'')+'/';
const partial=!exact&&state.backupSelections.some(path=>path.startsWith(prefix));
const hint=partial?'Ein oder mehrere Unterordner sind ausgewählt. Klicken, um den gesamten Ordner auszuwählen.':'Diesen Ordner als vollständige Backup-Quelle auswählen.';
return `<tr class="${partial?'bu-source-partial':''}"><td><input type="checkbox" class="bu-source-select" value="${esc(item.path)}" ${exact?'checked':''} data-partial="${partial?'true':'false'}" data-tooltip="${esc(hint)}"></td><td>Ordner</td><td>${esc(item.name)}${partial?'<span class="bu-partial-label">Teilweise ausgewählt</span>':''}</td><td>${esc(item.path)}</td><td>${button('Öffnen',`open-source-dir:${encodeURIComponent(item.path)}`)}</td></tr>`;
}).join('');
const chosen = state.backupSelections.length ? state.backupSelections.map(path=>`<span class="bu-selection">${esc(path)}</span>`).join('') : '<span class="bu-muted">Keine Ordner ausgewählt.</span>';
const error = state.sourceBrowserError ? `<div class="bu-inline-error">${esc(state.sourceBrowserError)}</div>` : '';
host.innerHTML = `<section class="bu-browser-card"><div class="bu-toolbar"><div><h3>Backup-Quellen auswählen</h3><span class="bu-muted">${esc(state.sourceBrowserPath)}</span></div><div class="bu-actions">${state.sourceBrowserPath!=='/'?button('Aktuellen Ordner auswählen','select-current-source'):''}${state.sourceBrowserPath!=='/'?button('Nach oben','source-up'):''}<span class="bu-count">Ausgewählt: ${state.backupSelections.length}</span></div></div>${error}<div class="bu-selection-list">${chosen}</div><div class="bu-browser-scroll"><table class="bu-table"><thead><tr><th>Auswahl</th><th>Typ</th><th>Name</th><th>Pfad</th><th></th></tr></thead><tbody>${rows||'<tr><td colspan="5" class="bu-empty">Keine Unterordner gefunden.</td></tr>'}</tbody></table></div></section>`;
host.querySelectorAll('.bu-source-select[data-partial="true"]').forEach(box=>{ box.indeterminate=true; box.setAttribute('aria-checked','mixed'); });
enhanceTooltips(host);
}