Fix relink: FilePond addFile API, yellow border, limbo type + await

- Fix addFile argument format: FilePond.addFile() takes (source, options)
  as two separate arguments, not a single {source, options} object.
- Change .filepond--file default border from accent-yellow to accent-green.
  Existing files loaded in edit mode have type 'local' and never reach
  processing-complete state, so they got the yellow border.
- Change relinked file add from type 'local' to 'limbo'. Limbo items
  go through DID_COMPLETE_ITEM_PROCESSING which triggers onprocessfile
  (ensures syncOrderInput runs with serverId available) and renders
  the green checkmark visual.
- Await addFile Promise and close modal in .then() instead of
  immediately, ensuring the item is created before cleanup.
- Remove duplicate modal.close() after the addFile block.
This commit is contained in:
Pontoporeia
2026-05-19 00:41:48 +02:00
parent ae9a8a62c0
commit b77bc486e5
3 changed files with 20 additions and 21 deletions

View File

@@ -30,6 +30,7 @@
- [x] JS: integrate relink button into FilePond UI (XamxamOpenFileBrowser + XamxamRelinkFile) - [x] JS: integrate relink button into FilePond UI (XamxamOpenFileBrowser + XamxamRelinkFile)
- [x] CSS: .relink-modal + .file-browser styles in form.css - [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: 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 - [ ] Migration: rename existing theses/ directories to documents/ on disk and update DB paths
## Trash policy ## Trash policy

View File

@@ -576,7 +576,7 @@
.filepond--file { .filepond--file {
color: var(--text-primary); color: var(--text-primary);
background-color: var(--bg-tertiary); background-color: var(--bg-tertiary);
border: 1px solid var(--accent-yellow); border: 1px solid var(--accent-green);
} }
.filepond--file .filepond--file-status { .filepond--file .filepond--file-status {

View File

@@ -636,22 +636,24 @@
var pond = FilePond.find(input); var pond = FilePond.find(input);
console.log('[relink] looking for pond | found=' + !!pond); console.log('[relink] looking for pond | found=' + !!pond);
if (pond) { if (pond) {
try { // Add as LIMBO to trigger server.load, which returns the actual file blob + headers.
pond.addFile({ // type: 'local' with file metadata skips load and may not render correctly.
source: String(data.id), pond.addFile(String(data.id), {
options: { type: 'limbo',
type: 'local',
file: { file: {
name: fileName, name: fileName,
size: fileSize, size: fileSize,
type: mimeType 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);
}); });
console.log('[relink] addFile called successfully | source=' + String(data.id) + ' | queueType=' + queueType);
} catch (e) {
console.error('[relink] addFile error', e);
}
} else { } else {
console.error('[relink] FilePond.find returned null for input', input); console.error('[relink] FilePond.find returned null for input', input);
} }
@@ -659,10 +661,6 @@
console.error('[relink] input not found | queueType=' + queueType); console.error('[relink] input not found | queueType=' + queueType);
} }
// Close modal
var modal = document.getElementById('relink-modal');
if (modal) modal.close();
// Mark form dirty // Mark form dirty
window.__xamxamDirty = true; window.__xamxamDirty = true;
}) })