Add classified evidence presentations
This commit is contained in:
+10
-2
@@ -1,4 +1,4 @@
|
||||
import type { BoardView, CaseState, Connection, Exhibit, ExhibitRelation, FolderExhibit, OrganizationKind, SourceFileType, TimelineRange, Viewport } from './types'
|
||||
import type { BoardView, CaseState, Connection, DocumentCaptureKind, Exhibit, ExhibitRelation, FolderExhibit, OrganizationKind, SourceFileType, TimelineRange, Viewport } from './types'
|
||||
|
||||
export interface BoardPoint { x: number; y: number }
|
||||
|
||||
@@ -233,6 +233,11 @@ function sourceFileType(value: unknown, mimeType: unknown): SourceFileType {
|
||||
return String(mimeType || '').startsWith('image/') ? 'image' : mimeType === 'application/pdf' ? 'pdf' : 'file'
|
||||
}
|
||||
|
||||
function documentCaptureKind(value: unknown): DocumentCaptureKind {
|
||||
const allowed: DocumentCaptureKind[] = ['unclassified', 'photo', 'scene', 'clipping', 'full_page']
|
||||
return allowed.includes(value as DocumentCaptureKind) ? value as DocumentCaptureKind : 'unclassified'
|
||||
}
|
||||
|
||||
/** Normalizes current API state and upgrades disposable pre-registry browser caches. */
|
||||
export function normalizeCase(input: CaseState | LegacyCaseState): CaseState {
|
||||
const state = input as LegacyCaseState
|
||||
@@ -243,7 +248,9 @@ export function normalizeCase(input: CaseState | LegacyCaseState): CaseState {
|
||||
goals: state.goals || [],
|
||||
report: state.report,
|
||||
views: Array.isArray(state.views) && state.views.length ? state.views : [defaultTimelineView(state.timelineRange)],
|
||||
exhibits: state.exhibits.map((exhibit, index) => ({ ...exhibit, ...placement(exhibit as unknown as Record<string, unknown>, { width: exhibit.type === 'document' ? 174 : 240, height: exhibit.type === 'document' ? 145 : 160 }, index) })),
|
||||
exhibits: state.exhibits.map((exhibit, index) => ({ ...exhibit,
|
||||
...(exhibit.type === 'document' ? { captureKind: documentCaptureKind(exhibit.captureKind) } : {}),
|
||||
...placement(exhibit as unknown as Record<string, unknown>, { width: exhibit.type === 'document' ? 174 : 240, height: exhibit.type === 'document' ? 145 : 160 }, index) })),
|
||||
updatedAt: state.updatedAt, levelStatus: state.levelStatus, sourceTemplateVersionId: state.sourceTemplateVersionId, editingAllowed: state.editingAllowed,
|
||||
newlyVisibleDocumentIds: state.newlyVisibleDocumentIds || [],
|
||||
}
|
||||
@@ -264,6 +271,7 @@ export function normalizeCase(input: CaseState | LegacyCaseState): CaseState {
|
||||
fileName: String(document.fileName || '') || undefined, mimeType: String(document.mimeType || '') || undefined,
|
||||
fileSize: document.fileSize === undefined ? undefined : Number(document.fileSize),
|
||||
fileType: sourceFileType(document.fileType, document.mimeType),
|
||||
captureKind: documentCaptureKind(document.captureKind),
|
||||
metadata: document.metadata && typeof document.metadata === 'object' ? document.metadata as Record<string, string> : {},
|
||||
} as Exhibit))
|
||||
const evidence: Exhibit[] = legacyEvidence.map((item, index) => {
|
||||
|
||||
Reference in New Issue
Block a user