diff --git a/apps/red-ui/src/app/models/audit-model-wrapper.model.ts b/apps/red-ui/src/app/models/audit-model-wrapper.model.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/red-ui/src/app/models/audit.model.ts b/apps/red-ui/src/app/models/audit.model.ts index d653e3099..76ca7d7ad 100644 --- a/apps/red-ui/src/app/models/audit.model.ts +++ b/apps/red-ui/src/app/models/audit.model.ts @@ -7,7 +7,7 @@ export class Audit implements IAudit, IListable { readonly details?: unknown; readonly message?: string; readonly objectId?: string; - readonly recordDate?: string; + readonly recordDate: string; readonly userId?: string; constructor(audit: IAudit) { @@ -20,7 +20,7 @@ export class Audit implements IAudit, IListable { this.userId = audit.userId; } - get id() { + get id(): string { return this.recordDate; } diff --git a/apps/red-ui/src/app/models/dictionary.ts b/apps/red-ui/src/app/models/dictionary.ts index bae65a716..53f4d6350 100644 --- a/apps/red-ui/src/app/models/dictionary.ts +++ b/apps/red-ui/src/app/models/dictionary.ts @@ -9,7 +9,7 @@ export class Dictionary implements IDictionary, IListable { readonly entries?: List; readonly hexColor?: string; readonly hint: boolean; - readonly label?: string; + readonly label: string; readonly rank?: number; readonly recommendation: boolean; diff --git a/apps/red-ui/src/app/models/file/file.ts b/apps/red-ui/src/app/models/file/file.ts index 2f7d82d22..e4b788de4 100644 --- a/apps/red-ui/src/app/models/file/file.ts +++ b/apps/red-ui/src/app/models/file/file.ts @@ -11,17 +11,17 @@ const processingStatuses: List = [ ] as const; export class File implements IFile, IListable { - readonly added: string; + readonly added?: string; readonly allManualRedactionsApplied: boolean; - readonly analysisDuration: number; + readonly analysisDuration?: number; readonly analysisRequired: boolean; - readonly approvalDate: string; - readonly currentReviewer: string; - readonly dictionaryVersion: number; - readonly dossierDictionaryVersion: number; + readonly approvalDate?: string; + readonly currentReviewer?: string; + readonly dictionaryVersion?: number; + readonly dossierDictionaryVersion?: number; readonly dossierId: string; readonly excluded: boolean; - readonly fileAttributes: FileAttributes; + readonly fileAttributes?: FileAttributes; readonly fileId: string; readonly filename: string; readonly hasAnnotationComments: boolean; @@ -29,20 +29,20 @@ export class File implements IFile, IListable { readonly hasImages: boolean; readonly hasRedactions: boolean; readonly hasUpdates: boolean; - readonly lastOCRTime: string; - readonly lastProcessed: string; - readonly lastReviewer: string; - readonly lastUpdated: string; - readonly lastUploaded: string; - readonly legalBasisVersion: number; - readonly numberOfAnalyses: number; - readonly numberOfPages: number; - readonly rulesVersion: number; + readonly lastOCRTime?: string; + readonly lastProcessed?: string; + readonly lastReviewer?: string; + readonly lastUpdated?: string; + readonly lastUploaded?: string; + readonly legalBasisVersion?: number; + readonly numberOfAnalyses?: number; + readonly numberOfPages?: number; + readonly rulesVersion?: number; readonly status: FileStatus; - readonly uploader: string; - readonly excludedPages: number[]; + readonly uploader?: string; + readonly excludedPages?: number[]; readonly hasSuggestions: boolean; - readonly dossierTemplateId: string; + readonly dossierTemplateId?: string; primaryAttribute: string; lastOpened: boolean; @@ -64,23 +64,23 @@ export class File implements IFile, IListable { constructor(file: IFile, public reviewerName: string, fileAttributesConfig?: FileAttributesConfig) { this.added = file.added; - this.allManualRedactionsApplied = file.allManualRedactionsApplied; + this.allManualRedactionsApplied = !!file.allManualRedactionsApplied; this.analysisDuration = file.analysisDuration; - this.analysisRequired = file.analysisRequired && !file.excluded; + this.analysisRequired = !!file.analysisRequired && !file.excluded; this.approvalDate = file.approvalDate; this.currentReviewer = file.currentReviewer; this.dictionaryVersion = file.dictionaryVersion; this.dossierDictionaryVersion = file.dossierDictionaryVersion; this.dossierId = file.dossierId; - this.excluded = file.excluded; + this.excluded = !!file.excluded; this.fileAttributes = file.fileAttributes; this.fileId = file.fileId; this.filename = file.filename; - this.hasAnnotationComments = file.hasAnnotationComments; - this.hasHints = file.hasHints; - this.hasImages = file.hasImages; - this.hasRedactions = file.hasRedactions; - this.hasUpdates = file.hasUpdates; + this.hasAnnotationComments = !!file.hasAnnotationComments; + this.hasHints = !!file.hasHints; + this.hasImages = !!file.hasImages; + this.hasRedactions = !!file.hasRedactions; + this.hasUpdates = !!file.hasUpdates; this.lastOCRTime = file.lastOCRTime; this.lastProcessed = file.lastProcessed; this.lastReviewer = file.lastReviewer; @@ -94,11 +94,13 @@ export class File implements IFile, IListable { this.rulesVersion = file.rulesVersion; this.uploader = file.uploader; this.excludedPages = file.excludedPages; - this.hasSuggestions = file.hasSuggestions; + this.hasSuggestions = !!file.hasSuggestions; this.dossierTemplateId = file.dossierTemplateId; this.statusSort = StatusSorter[this.status]; - this.cacheIdentifier = btoa(this.lastUploaded + this.lastOCRTime); + if (this.lastUpdated && this.lastOCRTime) { + this.cacheIdentifier = btoa(this.lastUploaded + this.lastOCRTime); + } this.hintsOnly = this.hasHints && !this.hasRedactions; this.hasNone = !this.hasRedactions && !this.hasHints && !this.hasSuggestions; this.isUnassigned = !this.currentReviewer; diff --git a/apps/red-ui/src/app/models/user.ts b/apps/red-ui/src/app/models/user.ts index 24bb45dd4..75d775736 100644 --- a/apps/red-ui/src/app/models/user.ts +++ b/apps/red-ui/src/app/models/user.ts @@ -5,8 +5,8 @@ import { KeycloakProfile } from 'keycloak-js'; export class User implements IUser, IListable { readonly email: string; readonly username: string; - readonly firstName: string; - readonly lastName: string; + readonly firstName?: string; + readonly lastName?: string; readonly name: string; readonly searchKey: string; diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts index 46a87f29b..e037a5b8c 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers.service.ts @@ -20,9 +20,9 @@ const getRelatedEvents = filter(event => event instanceof ActivationEnd && event }) export class DossiersService extends EntitiesService { readonly stats$ = this.all$.pipe(map(entities => this._computeStats(entities))); - readonly activeDossierId$: Observable; - readonly activeDossier$: Observable; - private readonly _activeDossierId$ = new BehaviorSubject(null); + readonly activeDossierId$: Observable; + readonly activeDossier$: Observable; + private readonly _activeDossierId$ = new BehaviorSubject(undefined); constructor(protected readonly _injector: Injector, private readonly _router: Router) { super(TEMPORARY_INJECTOR(_injector), 'dossier'); @@ -38,7 +38,7 @@ export class DossiersService extends EntitiesService { } if (dossierId === null || dossierId === undefined) { - return this._activeDossierId$.next(null); + return this._activeDossierId$.next(undefined); } // const notFound = !this.all.some(dossier => dossier.id === dossierId); diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index c0eeee9c7..0644fd983 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -22,10 +22,10 @@ import { FileAttributesService } from '../modules/dossier/services/file-attribut export interface AppState { dossiers: Dossier[]; dossierTemplates: DossierTemplate[]; - activeDossierId: string; - activeFileId: string; - activeDossierTemplateId: string; - activeDictionaryType: string; + activeDossierId?: string; + activeFileId?: string; + activeDossierTemplateId?: string; + activeDictionaryType?: string; totalAnalysedPages?: number; totalPeople?: number; } @@ -56,11 +56,7 @@ export class AppStateService { ) { this._appState = { dossiers: [], - dossierTemplates: [], - activeDossierId: null, - activeFileId: null, - activeDossierTemplateId: null, - activeDictionaryType: null + dossierTemplates: [] }; _router.events.subscribe((event: Event) => { @@ -74,14 +70,14 @@ export class AppStateService { return this.activateDossier(dossierId); } if (AppStateService._isRandomRoute(event)) { - this._appState.activeDossierId = null; + this._appState.activeDossierId = undefined; } }); } - private _dictionaryData: { [key: string]: { [key: string]: TypeValue } } = null; + private _dictionaryData?: { [key: string]: { [key: string]: TypeValue } }; - get dictionaryData(): { [key: string]: { [key: string]: TypeValue } } { + get dictionaryData(): { [key: string]: { [key: string]: TypeValue } } | undefined { return this._dictionaryData; } @@ -89,11 +85,11 @@ export class AppStateService { return this.allDossiers.reduce((acc, { files }) => [...acc, ...files], []); } - get activeDossierTemplateId(): string { + get activeDossierTemplateId(): string | undefined { return this._appState.activeDossierTemplateId; } - get activeDossierTemplate(): DossierTemplate { + get activeDossierTemplate(): DossierTemplate | undefined { return this.getDossierTemplateById(this.activeDossierTemplateId); } @@ -101,17 +97,20 @@ export class AppStateService { return this._appState.dossierTemplates; } - get activeDictionaryType(): string { + get activeDictionaryType(): string | undefined { return this._appState.activeDictionaryType; } - get activeDictionary(): TypeValue { - return this.activeDossierTemplateId && this.dictionaryData[this.activeDossierTemplateId] + get activeDictionary(): TypeValue | undefined { + return this.activeDossierTemplateId && + this.activeDictionaryType && + this.dictionaryData && + this.dictionaryData[this.activeDossierTemplateId] ? this.dictionaryData[this.activeDossierTemplateId][this.activeDictionaryType] - : null; + : undefined; } - get activeDossierId(): string { + get activeDossierId(): string | undefined { return this._appState.activeDossierId; } @@ -131,15 +130,15 @@ export class AppStateService { return this.activeDossier?.files.find(f => f.fileId === this.activeFileId); } - get activeFileId(): string { + get activeFileId(): string | undefined { return this._appState.activeFileId; } - get totalAnalysedPages(): number { + get totalAnalysedPages(): number | undefined { return this._appState.totalAnalysedPages; } - get totalPeople(): number { + get totalPeople(): number | undefined { return this._appState.totalPeople; } @@ -170,18 +169,26 @@ export class AppStateService { if (!dossierTemplateId) { dossierTemplateId = this.dossierTemplates[0]?.dossierTemplateId; } - if (!dossierTemplateId) { + + if (!dossierTemplateId || !this._dictionaryData) { return '#cccccc'; } - const color = this._dictionaryData[dossierTemplateId][type]?.hexColor; + + let color; + if (type) { + color = this._dictionaryData[dossierTemplateId][type]?.hexColor; + } return color ?? this._dictionaryData[dossierTemplateId]['default'].hexColor; } - getDossierTemplateById(id: string): DossierTemplate { + getDossierTemplateById(id?: string): DossierTemplate | undefined { + if (!id) { + return undefined; + } return this.dossierTemplates.find(rs => rs.dossierTemplateId === id); } - getDictionaryTypeValue(key: string, dossierTemplateId?: string): TypeValue { + getDictionaryTypeValue(key: string, dossierTemplateId?: string): TypeValue | undefined { if (!dossierTemplateId && this.activeDossier) { dossierTemplateId = this.activeDossier.dossierTemplateId; } @@ -189,7 +196,7 @@ export class AppStateService { if (!dossierTemplateId) { dossierTemplateId = this.dossierTemplates.length > 0 ? this.dossierTemplates[0].dossierTemplateId : undefined; } - if (!dossierTemplateId) { + if (!dossierTemplateId || !this._dictionaryData) { return undefined; } @@ -216,7 +223,9 @@ export class AppStateService { for (const dossierId of Object.keys(fileData)) { const dossier = mappedDossiers.find(p => p.id === dossierId); - this._processFiles(dossier, fileData[dossierId], emitEvents); + if (dossier) { + this._processFiles(dossier, fileData[dossierId], emitEvents); + } } this._appState.dossiers = mappedDossiers; diff --git a/apps/red-ui/src/app/state/model/dossier-attribute-config.ts b/apps/red-ui/src/app/state/model/dossier-attribute-config.ts index 28da877ca..087c3081b 100644 --- a/apps/red-ui/src/app/state/model/dossier-attribute-config.ts +++ b/apps/red-ui/src/app/state/model/dossier-attribute-config.ts @@ -4,9 +4,10 @@ import { IListable } from '@iqser/common-ui'; export class DossierAttributeConfig implements IDossierAttributeConfig, IListable { readonly id: string; readonly editable: boolean; - readonly label?: string; + readonly label: string; readonly placeholder?: string; readonly type?: DossierAttributeConfigType; + readonly dossierTemplateId: string; constructor(dossierAttributeConfig: IDossierAttributeConfig) { this.id = dossierAttributeConfig.id; @@ -14,6 +15,7 @@ export class DossierAttributeConfig implements IDossierAttributeConfig, IListabl this.label = dossierAttributeConfig.label; this.placeholder = dossierAttributeConfig.placeholder; this.type = dossierAttributeConfig.type; + this.dossierTemplateId = dossierAttributeConfig.dossierTemplateId; } get searchKey(): string { diff --git a/apps/red-ui/src/app/state/model/dossier.ts b/apps/red-ui/src/app/state/model/dossier.ts index 6e2ec7389..e70dc6972 100644 --- a/apps/red-ui/src/app/state/model/dossier.ts +++ b/apps/red-ui/src/app/state/model/dossier.ts @@ -4,20 +4,20 @@ import { IListable } from '@iqser/common-ui'; export class Dossier implements IDossier, IListable { readonly dossierId: string; - readonly ownerId: string; - readonly memberIds: List; - readonly approverIds: List; - readonly reportTemplateIds: List; readonly dossierTemplateId: string; + readonly ownerId: string; + readonly memberIds?: List; + readonly approverIds?: List; + readonly reportTemplateIds?: List; readonly dossierName: string; - readonly date: string; - readonly description: string; - readonly downloadFileTypes: List; - readonly dueDate: string; - readonly hardDeletedTime: string; - readonly reportTypes: List; - readonly softDeletedTime: string; - readonly status: DossierStatus; + readonly date?: string; + readonly dueDate?: string; + readonly description?: string; + readonly downloadFileTypes?: List; + readonly hardDeletedTime?: string; + readonly reportTypes?: List; + readonly softDeletedTime?: string; + readonly status?: DossierStatus; readonly watermarkEnabled: boolean; readonly hasReviewers: boolean; @@ -25,7 +25,7 @@ export class Dossier implements IDossier, IListable { hasFiles = this._files.length > 0; filesLength = this._files.length; - totalNumberOfPages?: number; + totalNumberOfPages = 0; hintsOnly?: boolean; hasRedactions?: boolean; hasSuggestions?: boolean; @@ -51,8 +51,8 @@ export class Dossier implements IDossier, IListable { this.reportTypes = dossier.reportTypes; this.softDeletedTime = dossier.softDeletedTime; this.status = dossier.status; - this.watermarkEnabled = dossier.watermarkEnabled; - this.hasReviewers = this.memberIds.length > 1; + this.watermarkEnabled = !!dossier.watermarkEnabled; + this.hasReviewers = !!this.memberIds && this.memberIds.length > 1; this._recomputeFileStatus(); } @@ -83,7 +83,7 @@ export class Dossier implements IDossier, IListable { } hasMember(memberId: string): boolean { - return this.memberIds.indexOf(memberId) >= 0; + return !!this.memberIds && this.memberIds.indexOf(memberId) >= 0; } private _recomputeFileStatus() { @@ -99,7 +99,7 @@ export class Dossier implements IDossier, IListable { this.hasRedactions = this.hasRedactions || f.hasRedactions; this.hasSuggestions = this.hasSuggestions || f.hasSuggestions; this.allFilesApproved = this.allFilesApproved && f.isApproved; - this.totalNumberOfPages += f.numberOfPages; + this.totalNumberOfPages += f.numberOfPages ?? 0; this.hasPendingOrProcessing = this.hasPendingOrProcessing || f.isPending || f.isProcessing; }); this.hasNone = !this.hasSuggestions && !this.hasRedactions && !this.hintsOnly; diff --git a/apps/red-ui/src/app/state/model/dossier.wrapper.ts b/apps/red-ui/src/app/state/model/dossier.wrapper.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/common-ui b/libs/common-ui index c0b445b06..25d66040d 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit c0b445b06ed86a07c4b9aa1803b29b9384021d54 +Subproject commit 25d66040d01d06520a4497d88395903b95121e3b diff --git a/libs/red-ui-http/src/lib/model/audit.ts b/libs/red-ui-http/src/lib/model/audit.ts index 940f7eb76..2a94b2242 100644 --- a/libs/red-ui-http/src/lib/model/audit.ts +++ b/libs/red-ui-http/src/lib/model/audit.ts @@ -15,7 +15,7 @@ export interface IAudit { readonly details?: unknown; readonly message?: string; readonly objectId?: string; - readonly recordDate?: string; + readonly recordDate: string; readonly recordId?: number; readonly userId?: string; } diff --git a/libs/red-ui-http/src/lib/model/dictionary.ts b/libs/red-ui-http/src/lib/model/dictionary.ts index 5bfd45658..0754fb732 100644 --- a/libs/red-ui-http/src/lib/model/dictionary.ts +++ b/libs/red-ui-http/src/lib/model/dictionary.ts @@ -47,7 +47,7 @@ export interface IDictionary { /** * Label of the type */ - readonly label?: string; + readonly label: string; /** * The rank of this dictionary, higher rank means higher importance. */ diff --git a/libs/red-ui-http/src/lib/model/dossier.ts b/libs/red-ui-http/src/lib/model/dossier.ts index f87e6224b..0e48a239c 100644 --- a/libs/red-ui-http/src/lib/model/dossier.ts +++ b/libs/red-ui-http/src/lib/model/dossier.ts @@ -12,17 +12,17 @@ import { List } from '../red-types'; export interface IDossier { + readonly dossierId: string; + readonly dossierName: string; + readonly dossierTemplateId: string; readonly approverIds?: List; readonly date?: string; readonly description?: string; - readonly dossierId?: string; - readonly dossierName?: string; - readonly dossierTemplateId?: string; readonly downloadFileTypes?: List; readonly dueDate?: string; readonly hardDeletedTime?: string; readonly memberIds?: List; - readonly ownerId?: string; + readonly ownerId: string; readonly reportTemplateIds?: List; readonly reportTypes?: List; readonly softDeletedTime?: string; diff --git a/libs/red-ui-http/src/lib/model/dossierAttributeConfig.ts b/libs/red-ui-http/src/lib/model/dossierAttributeConfig.ts index ba1173cad..d41f90b65 100644 --- a/libs/red-ui-http/src/lib/model/dossierAttributeConfig.ts +++ b/libs/red-ui-http/src/lib/model/dossierAttributeConfig.ts @@ -13,9 +13,9 @@ export interface IDossierAttributeConfig { readonly id: string; readonly editable?: boolean; - readonly label?: string; + readonly label: string; readonly placeholder?: string; - readonly dossierTemplateId?: string; + readonly dossierTemplateId: string; readonly type?: DossierAttributeConfigType; } diff --git a/libs/red-ui-http/src/lib/model/file.ts b/libs/red-ui-http/src/lib/model/file.ts index 1d5212519..82613b308 100644 --- a/libs/red-ui-http/src/lib/model/file.ts +++ b/libs/red-ui-http/src/lib/model/file.ts @@ -9,7 +9,7 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import { FileAttributes } from './fileAttributes'; +import { FileAttributes } from "./fileAttributes"; /** * Object containing information on a specific file. @@ -50,7 +50,7 @@ export interface IFile { /** * The ID of the dossier the file belongs to. */ - readonly dossierId?: string; + readonly dossierId: string; /** * The dossierTemplateId for this file. */ @@ -67,11 +67,11 @@ export interface IFile { /** * The ID of the file. */ - readonly fileId?: string; + readonly fileId: string; /** * The file's name. */ - readonly filename?: string; + readonly filename: string; /** * Shows if this file has comments on annotations. */ @@ -147,7 +147,7 @@ export interface IFile { /** * The status of the file with regard to its analysis an review processes. */ - readonly status?: FileStatus; + readonly status: FileStatus; /** * The ID of the user who uploaded the file. */ diff --git a/libs/red-ui-http/src/lib/model/user.ts b/libs/red-ui-http/src/lib/model/user.ts index 12c831294..c51160c70 100644 --- a/libs/red-ui-http/src/lib/model/user.ts +++ b/libs/red-ui-http/src/lib/model/user.ts @@ -17,7 +17,7 @@ export interface IUser { /** * Email of user. */ - readonly email?: string; + readonly email: string; /** * First name of user. */