Lisää kansion poisto -toiminto dokumenttien hallintaan

- Poisto-nappi (🗑) näkyy kansion päällä hover-tilassa
- Vahvistusikkuna ennen poistoa
- Kansion dokumentit ja alikansiot siirtyvät ylätasolle poistettaessa

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 00:24:01 +02:00
parent 7ed17c163f
commit f913a87b14
2 changed files with 12 additions and 1 deletions

View File

@@ -4921,7 +4921,7 @@ function renderDocFolderBar() {
const subfolders = allDocFolders.filter(f => (f.parent_id || null) === currentDocFolderId); const subfolders = allDocFolders.filter(f => (f.parent_id || null) === currentDocFolderId);
const grid = document.getElementById('doc-folders-grid'); const grid = document.getElementById('doc-folders-grid');
grid.innerHTML = subfolders.map(f => grid.innerHTML = subfolders.map(f =>
`<div class="doc-folder-item" onclick="navigateDocFolder('${f.id}')">📁 ${esc(f.name)}</div>` `<div class="doc-folder-item" onclick="navigateDocFolder('${f.id}')">📁 ${esc(f.name)}<button class="doc-folder-delete" onclick="event.stopPropagation();deleteDocFolder('${f.id}','${esc(f.name)}')" title="Poista kansio">🗑</button></div>`
).join(''); ).join('');
} }
@@ -4944,6 +4944,14 @@ function navigateDocFolder(folderId) {
renderDocumentsList(); renderDocumentsList();
} }
async function deleteDocFolder(folderId, folderName) {
if (!confirm(`Poistetaanko kansio "${folderName}"?\n\nKansion dokumentit ja alikansiot siirretään ylätasolle.`)) return;
try {
await apiCall('document_folder_delete', 'POST', { id: folderId });
await loadDocuments();
} catch (e) { alert('Kansion poisto epäonnistui: ' + e.message); }
}
// ---- Sub-tabit ---- // ---- Sub-tabit ----
function switchDocSubTab(target) { function switchDocSubTab(target) {

View File

@@ -1621,6 +1621,9 @@ span.empty {
transition: background 0.15s, border-color 0.15s; transition: background 0.15s, border-color 0.15s;
} }
.doc-folder-item:hover { background: #e5e7eb; } .doc-folder-item:hover { background: #e5e7eb; }
.doc-folder-delete { background: none; border: none; cursor: pointer; font-size: 0.75rem; padding: 0 0.15rem; opacity: 0; transition: opacity 0.15s; margin-left: 0.25rem; }
.doc-folder-item:hover .doc-folder-delete { opacity: 0.6; }
.doc-folder-delete:hover { opacity: 1 !important; }
#doc-breadcrumbs a { color: var(--primary-color); text-decoration: none; font-weight: 500; } #doc-breadcrumbs a { color: var(--primary-color); text-decoration: none; font-weight: 500; }
#doc-breadcrumbs a:hover { text-decoration: underline; } #doc-breadcrumbs a:hover { text-decoration: underline; }