diff --git a/frontend/js/upload.js b/frontend/js/upload.js index d7f39b4..7d0012f 100644 --- a/frontend/js/upload.js +++ b/frontend/js/upload.js @@ -250,8 +250,9 @@ export async function promptTargetFolder(initialVault, initialDir = '', items = if (vaultFoldersMap[v]) return vaultFoldersMap[v]; try { const res = await api(`/api/vault/${encodeURIComponent(v)}/paths?limit=5000`); - if (res && Array.isArray(res.paths)) { - vaultFoldersMap[v] = res.paths + const list = res?.results || res?.paths || []; + if (Array.isArray(list)) { + vaultFoldersMap[v] = list .filter((p) => p.type === 'directory') .map((p) => p.path) .sort(); @@ -275,6 +276,8 @@ export async function promptTargetFolder(initialVault, initialDir = '', items = const fileCount = items.filter((x) => !x.isDir).length; const dirCount = items.filter((x) => x.isDir).length; + let filterText = ''; + function renderVaultOptions() { return vaultsList.map((v) => { const vName = typeof v === 'string' ? v : v.name; @@ -283,17 +286,26 @@ export async function promptTargetFolder(initialVault, initialDir = '', items = }).join(''); } - function renderFolderOptions(folders, curDir) { + function renderFolderOptions(folders, curDir, filter = '') { + let filtered = folders; + if (filter.trim()) { + const q = filter.trim().toLowerCase(); + filtered = folders.filter((f) => f.toLowerCase().includes(q)); + } + let html = ``; - for (const folder of folders) { + for (const folder of filtered) { const sel = folder === curDir ? 'selected' : ''; - html += ``; + // Indent subfolder depth for a clean hierarchical visual tree + const depth = (folder.match(/\//g) || []).length; + const indent = ' '.repeat(depth); + html += ``; } return html; } overlay.innerHTML = ` -