Add drag-to-trash exhibit disposal
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user