Remove an Attached Document from an Activity
The Document Attach Widget provides remove controls (e.g., a delete icon) on each document thumbnail. Tapping the remove control prompts a confirmation before deleting. On confirmation, the Activity Document Repository removes the metadata record (cascade delete is configured) and the Document Storage Service deletes the file and its associated thumbnail from the Supabase Storage bucket. Only the user who attached the document or a coordinator with appropriate permissions can remove documents.
User Story
As a
user
I want
to remove an incorrectly attached document from an activity
So that
So that I can correct mistakes and ensure only relevant and accurate documentary evidence is associated with the activity record
Acceptance Criteria
- Given the user is viewing the document attach widget, when they tap the remove control on a document thumbnail, then a confirmation dialog appears asking them to confirm deletion
- Given the user confirms deletion, when the delete operation completes, then the document thumbnail is removed from the attach widget and the metadata record is deleted from the activity_documents table
- Given the document is deleted from the database, when the deletion propagates, then the corresponding file and thumbnail are also removed from the Supabase Storage bucket
- Given the user cancels the confirmation dialog, when they cancel, then the document remains attached and no changes are made
- Given a peer mentor attempts to remove a document attached by a coordinator, when permissions are checked, then only the owning user or a coordinator can successfully delete the document
Business Value
Allowing document removal prevents incorrect or irrelevant evidence from polluting activity records. Clean, accurate evidence chains are essential for Bufdir audit credibility — a single misattached document could undermine the legitimacy of a report.
Components
- Document Attach Widget ui
- Document Storage Service service
- Activity Document Repository data
- File Storage Backend infrastructure