update types / undefineds

This commit is contained in:
Dan Percic 2021-09-29 18:47:09 +03:00
parent b73b9fb637
commit 065fe432f6
17 changed files with 112 additions and 99 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -11,17 +11,17 @@ const processingStatuses: List<FileStatus> = [
] 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;

View File

@ -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;

View File

@ -20,9 +20,9 @@ const getRelatedEvents = filter(event => event instanceof ActivationEnd && event
})
export class DossiersService extends EntitiesService<Dossier, IDossier> {
readonly stats$ = this.all$.pipe(map(entities => this._computeStats(entities)));
readonly activeDossierId$: Observable<string | null>;
readonly activeDossier$: Observable<Dossier | null>;
private readonly _activeDossierId$ = new BehaviorSubject<string | null>(null);
readonly activeDossierId$: Observable<string | undefined>;
readonly activeDossier$: Observable<Dossier | undefined>;
private readonly _activeDossierId$ = new BehaviorSubject<string | undefined>(undefined);
constructor(protected readonly _injector: Injector, private readonly _router: Router) {
super(TEMPORARY_INJECTOR(_injector), 'dossier');
@ -38,7 +38,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
}
if (dossierId === null || dossierId === undefined) {
return this._activeDossierId$.next(null);
return this._activeDossierId$.next(undefined);
}
// const notFound = !this.all.some(dossier => dossier.id === dossierId);

View File

@ -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;

View File

@ -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 {

View File

@ -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<DownloadFileType>;
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<DownloadFileType>;
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;

@ -1 +1 @@
Subproject commit c0b445b06ed86a07c4b9aa1803b29b9384021d54
Subproject commit 25d66040d01d06520a4497d88395903b95121e3b

View File

@ -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;
}

View File

@ -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.
*/

View File

@ -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<DownloadFileType>;
readonly dueDate?: string;
readonly hardDeletedTime?: string;
readonly memberIds?: List;
readonly ownerId?: string;
readonly ownerId: string;
readonly reportTemplateIds?: List;
readonly reportTypes?: List;
readonly softDeletedTime?: string;

View File

@ -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;
}

View File

@ -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.
*/

View File

@ -17,7 +17,7 @@ export interface IUser {
/**
* Email of user.
*/
readonly email?: string;
readonly email: string;
/**
* First name of user.
*/