78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
import { IListable, List } from '@iqser/common-ui';
|
|
import { IDossier } from './dossier';
|
|
import { DownloadFileType } from '../shared';
|
|
import { ARCHIVE_ROUTE, DOSSIERS_ROUTE } from './constants';
|
|
|
|
export class Dossier implements IDossier, IListable {
|
|
readonly dossierId: string;
|
|
readonly dossierTemplateId: string;
|
|
readonly ownerId: string;
|
|
readonly memberIds: List;
|
|
readonly approverIds: List;
|
|
readonly reportTemplateIds: List;
|
|
readonly dossierName: string;
|
|
readonly dossierStatusId: string;
|
|
readonly date: string;
|
|
readonly dueDate?: string;
|
|
readonly description?: string;
|
|
readonly downloadFileTypes?: List<DownloadFileType>;
|
|
readonly hardDeletedTime?: string;
|
|
readonly softDeletedTime?: string;
|
|
readonly startDate?: string;
|
|
readonly watermarkId?: number;
|
|
readonly previewWatermarkId?: number;
|
|
readonly archivedTime: string;
|
|
readonly hasReviewers: boolean;
|
|
readonly routerLink: string;
|
|
readonly dossiersListRouterLink: string;
|
|
readonly id: string;
|
|
changedDate?: string;
|
|
|
|
constructor(dossier: IDossier) {
|
|
this.dossierId = dossier.dossierId;
|
|
this.approverIds = dossier.approverIds;
|
|
this.date = dossier.date;
|
|
this.description = dossier.description;
|
|
this.dossierName = dossier.dossierName;
|
|
this.dossierStatusId = dossier.dossierStatusId;
|
|
this.dossierTemplateId = dossier.dossierTemplateId;
|
|
this.downloadFileTypes = dossier.downloadFileTypes;
|
|
this.dueDate = dossier.dueDate;
|
|
this.hardDeletedTime = dossier.hardDeletedTime;
|
|
this.memberIds = dossier.memberIds;
|
|
this.ownerId = dossier.ownerId;
|
|
this.reportTemplateIds = dossier.reportTemplateIds;
|
|
this.softDeletedTime = dossier.softDeletedTime;
|
|
this.startDate = dossier.startDate;
|
|
this.watermarkId = dossier.watermarkId;
|
|
this.previewWatermarkId = dossier.previewWatermarkId;
|
|
this.archivedTime = dossier.archivedTime;
|
|
this.hasReviewers = !!this.memberIds && this.memberIds.length > 1;
|
|
|
|
this.id = this.dossierId;
|
|
const routerPath = this.isArchived ? ARCHIVE_ROUTE : DOSSIERS_ROUTE;
|
|
this.dossiersListRouterLink = `/main/${this.dossierTemplateId}/${routerPath}`;
|
|
this.routerLink = `${this.dossiersListRouterLink}/${this.dossierId}`;
|
|
}
|
|
|
|
get searchKey(): string {
|
|
return this.dossierName;
|
|
}
|
|
|
|
get isActive(): boolean {
|
|
return !this.isSoftDeleted && !this.isArchived;
|
|
}
|
|
|
|
get isArchived(): boolean {
|
|
return this.archivedTime !== null;
|
|
}
|
|
|
|
get isSoftDeleted(): boolean {
|
|
return this.softDeletedTime !== null;
|
|
}
|
|
|
|
hasMember(memberId: string): boolean {
|
|
return !!this.memberIds && this.memberIds.indexOf(memberId) >= 0;
|
|
}
|
|
}
|