diff --git a/TODO.md b/TODO.md index 5367084..6bf8a92 100644 --- a/TODO.md +++ b/TODO.md @@ -30,6 +30,7 @@ - [x] JS: integrate relink button into FilePond UI (XamxamOpenFileBrowser + XamxamRelinkFile) - [x] CSS: .relink-modal + .file-browser styles in form.css - [x] Fix: relinked file not appearing in FilePond pool — add file metadata to addFile() options and extensive diag logging +- [x] Fix: addFile called with single object instead of (source, options) — FilePond API mismatch prevented files from loading - [ ] Migration: rename existing theses/ directories to documents/ on disk and update DB paths ## Trash policy diff --git a/app/public/assets/css/form.css b/app/public/assets/css/form.css index 62daa9f..c608d6a 100644 --- a/app/public/assets/css/form.css +++ b/app/public/assets/css/form.css @@ -576,7 +576,7 @@ .filepond--file { color: var(--text-primary); background-color: var(--bg-tertiary); - border: 1px solid var(--accent-yellow); + border: 1px solid var(--accent-green); } .filepond--file .filepond--file-status { diff --git a/app/public/assets/js/app/file-upload-filepond.js b/app/public/assets/js/app/file-upload-filepond.js index 7acf5a2..694f096 100644 --- a/app/public/assets/js/app/file-upload-filepond.js +++ b/app/public/assets/js/app/file-upload-filepond.js @@ -636,22 +636,24 @@ var pond = FilePond.find(input); console.log('[relink] looking for pond | found=' + !!pond); if (pond) { - try { - pond.addFile({ - source: String(data.id), - options: { - type: 'local', - file: { - name: fileName, - size: fileSize, - type: mimeType - } - }, - }); - console.log('[relink] addFile called successfully | source=' + String(data.id) + ' | queueType=' + queueType); - } catch (e) { - console.error('[relink] addFile error', e); - } + // Add as LIMBO to trigger server.load, which returns the actual file blob + headers. + // type: 'local' with file metadata skips load and may not render correctly. + pond.addFile(String(data.id), { + type: 'limbo', + file: { + name: fileName, + size: fileSize, + type: mimeType + } + }).then(function() { + console.log('[relink] addFile resolved | source=' + String(data.id) + ' | queueType=' + queueType); + // Close modal after file is added to the pond. + // syncOrderInput fires via onprocessfile / onupdatefiles. + var modal = document.getElementById('relink-modal'); + if (modal) modal.close(); + }).catch(function(err) { + console.error('[relink] addFile rejected', err); + }); } else { console.error('[relink] FilePond.find returned null for input', input); } @@ -659,10 +661,6 @@ console.error('[relink] input not found | queueType=' + queueType); } - // Close modal - var modal = document.getElementById('relink-modal'); - if (modal) modal.close(); - // Mark form dirty window.__xamxamDirty = true; })