Add drag-to-trash exhibit disposal

This commit is contained in:
2026-08-14 19:37:43 +02:00
parent 18705fe55f
commit 703b9652c9
5 changed files with 103 additions and 4 deletions
+23
View File
@@ -178,6 +178,29 @@ export function relationPosition(state: CaseState, relation: WidgetRelation) {
}
}
export function discardExhibit(state: CaseState, exhibitId: string): CaseState {
if (!state.evidence.some(exhibit => exhibit.id === exhibitId)) return state
return {
...state,
evidence: state.evidence
.filter(exhibit => exhibit.id !== exhibitId)
.map(exhibit => ({
...exhibit,
containedDocumentIds: exhibit.containedDocumentIds?.filter(id => id !== exhibitId),
supportingEvidenceIds: exhibit.supportingEvidenceIds?.filter(id => id !== exhibitId),
relatedEvidenceIds: exhibit.relatedEvidenceIds?.filter(id => id !== exhibitId),
})),
relations: state.relations.filter(relation => relation.fromWidgetId !== exhibitId && relation.toWidgetId !== exhibitId),
connections: state.connections.filter(connection => connection.fromEvidenceId !== exhibitId && connection.toEvidenceId !== exhibitId),
brief: {
...state.brief,
concepts: state.brief.concepts.map(concept => concept.resolvedPartyExhibitId === exhibitId
? { ...concept, resolvedPartyExhibitId: undefined }
: concept),
},
}
}
export function normalizeCase(state: CaseState): CaseState {
const relations = Array.isArray(state.relations)
? state.relations