facett-file — design note
Status: builds (egui 0.33) + 3 tests green. In ordning/crates/widgets/facett-file; destined for facett.
What it is
A file-attachment surface: a drop zone (OS drag-and-drop) + an attachment list (icon, name, human size) with remove buttons. In the ärende profile an attachment is a handling — this widget is the upload/list UI; the legal metadata (direction, diarienummer, sekretess) lives on the case.
API
let mut files = Files::new();
files.set_files(vec![FileRef::new("ansökan.pdf", 240_000, "application/pdf"), …]);
files.ui(ui); // drop zone + list
for added in files.take_added() { /* host persists, then set_files(authoritative) */ }
for name in files.take_removed() { /* host deletes */ }
Design decisions
- Reports intents, does no I/O. Dropped files and removals are surfaced via
take_added/take_removed; the host owns persistence (and, in ärende mode, diarieföring of the handling). - Reads OS drops from
ctx.input().raw.dropped_files; highlights the zone while files hover. - Icon + human size by mime/extension;
read_onlymode (e.g. archived ärenden) hides the zone + remove buttons. state_jsonexposes files, total size, pending intents → headless.
TODO on move
- Thumbnail previews for images; PDF/A nudge for ärende uploads; per-file sekretess marking hook; progress for large uploads; theme the zone.