diff --git a/apps/red-ui/src/app/models/file/file-status.wrapper.ts b/apps/red-ui/src/app/models/file/file-status.wrapper.ts index 0b43d0b05..2711b3195 100644 --- a/apps/red-ui/src/app/models/file/file-status.wrapper.ts +++ b/apps/red-ui/src/app/models/file/file-status.wrapper.ts @@ -1,23 +1,55 @@ import { FileAttributesConfig, FileStatus } from '@redaction/red-ui-http'; import { StatusSorter } from '@utils/sorters/status-sorter'; -export class FileStatusWrapper { +const processingStatuses = [ + FileStatus.StatusEnum.REPROCESS, + FileStatus.StatusEnum.FULLREPROCESS, + FileStatus.StatusEnum.OCRPROCESSING, + FileStatus.StatusEnum.INDEXING, + FileStatus.StatusEnum.PROCESSING +] as const; + +export class FileStatusWrapper implements FileStatus { + readonly added = this.fileStatus.added; + readonly allManualRedactionsApplied = this.fileStatus.allManualRedactionsApplied; + readonly analysisDuration = this.fileStatus.analysisDuration; + readonly analysisRequired = this.fileStatus.analysisRequired && !this.fileStatus.excluded; + readonly approvalDate = this.fileStatus.approvalDate; + currentReviewer = this.fileStatus.currentReviewer; + readonly dictionaryVersion = this.fileStatus.dictionaryVersion; + readonly dossierDictionaryVersion = this.fileStatus.dossierDictionaryVersion; + readonly dossierId = this.fileStatus.dossierId; + readonly excluded = this.fileStatus.excluded; + readonly fileAttributes = this.fileStatus.fileAttributes; + readonly fileId = this.fileStatus.fileId; + readonly filename = this.fileStatus.filename; + readonly hasAnnotationComments = this.fileStatus.hasAnnotationComments; + readonly hasHints = this.fileStatus.hasHints; + readonly hasImages = this.fileStatus.hasImages; + readonly hasRedactions = this.fileStatus.hasRedactions; + readonly hasRequests = this.fileStatus.hasRequests; + readonly hasUpdates = this.fileStatus.hasUpdates; + readonly lastOCRTime = this.fileStatus.lastOCRTime; + readonly lastProcessed = this.fileStatus.lastProcessed; + readonly lastReviewer = this.fileStatus.lastReviewer; + readonly lastUpdated = this.fileStatus.lastUpdated; + readonly lastUploaded = this.fileStatus.lastUploaded; + readonly legalBasisVersion = this.fileStatus.legalBasisVersion; + readonly numberOfAnalyses = this.fileStatus.numberOfAnalyses; + readonly numberOfPages = this.fileStatus.numberOfPages; + readonly rulesVersion = this.fileStatus.rulesVersion; + readonly status = this._status; + readonly uploader = this.fileStatus.uploader; + readonly excludedPages = this.fileStatus.excludedPages; + primaryAttribute: string; - searchField: string; - - constructor( - public fileStatus: FileStatus, - public reviewerName: string, - public dossierTemplateId: string, - fileAttributesConfig?: FileAttributesConfig - ) { - this.searchField = fileStatus.filename; + constructor(readonly fileStatus: FileStatus, public reviewerName: string, fileAttributesConfig?: FileAttributesConfig) { if (fileAttributesConfig) { const primary = fileAttributesConfig.fileAttributeConfigs?.find(c => c.primaryAttribute); if (primary && fileStatus.fileAttributes?.attributeIdToValue) { this.primaryAttribute = fileStatus.fileAttributes?.attributeIdToValue[primary.id]; - this.searchField += ' ' + this.primaryAttribute; + this.filename += ' ' + this.primaryAttribute; } if (!this.primaryAttribute) { @@ -27,178 +59,40 @@ export class FileStatusWrapper { } } - get analysisDuration() { - return this.fileStatus.analysisDuration; + readonly excludedPagesCount = this.excludedPages?.length ?? 0; + readonly statusSort = StatusSorter[this.status]; + readonly pages = this._pages; + readonly cacheIdentifier = btoa(this.lastUploaded + this.lastOCRTime); + + readonly hasUnappliedSuggestions = !this.allManualRedactionsApplied; + readonly hintsOnly = this.hasHints && !this.hasRedactions; + readonly hasNone = !this.hasRedactions && !this.hasHints && !this.hasRequests; + + readonly isError = this.status === FileStatus.StatusEnum.ERROR; + readonly isProcessing = processingStatuses.includes(this.status); + readonly isApproved = this.status === FileStatus.StatusEnum.APPROVED; + readonly isPending = this.status === FileStatus.StatusEnum.UNPROCESSED; + readonly isUnderReview = this.status === FileStatus.StatusEnum.UNDERREVIEW; + readonly isUnderApproval = this.status === FileStatus.StatusEnum.UNDERAPPROVAL; + readonly canBeApproved = !this.analysisRequired && !this.hasRequests; + readonly canBeOpened = !this.isError && !this.isPending; + readonly isWorkable = !this.isProcessing && this.canBeOpened; + readonly canBeOCRed = !this.excluded && !this.lastOCRTime && ['UNASSIGNED', 'UNDER_REVIEW', 'UNDER_APPROVAL'].includes(this.status); + + get isUnassigned() { + return !this.currentReviewer; } - get lastProcessed() { - return this.fileStatus.lastProcessed; - } - - get added() { - return this.fileStatus.added; - } - - get lastUploaded() { - return this.fileStatus.lastUploaded; - } - - get hasImages() { - return this.fileStatus.hasImages; - } - - get hasUpdates() { - return this.fileStatus.hasUpdates && !this.hasRequests; - } - - get hasUnappliedSuggestions() { - return !this.fileStatus.allManualRedactionsApplied; - } - - get currentReviewer() { - return this.fileStatus.currentReviewer; - } - - set currentReviewer(value: string) { - this.fileStatus.currentReviewer = value; - } - - get fileId() { - return this.fileStatus.fileId; - } - - get filename() { - return this.fileStatus.filename; - } - - get hasAnnotationComments() { - // return this.fileStatus.hasAnnotationComments; - // TODO remove this once backend works properly - return false; - } - - get ocrTime() { - return this.fileStatus.lastOCRTime; - } - - get hasHints() { - return this.fileStatus.hasHints; - } - - get hintsOnly() { - return this.fileStatus.hasHints && !this.fileStatus.hasRedactions; - } - - get hasRedactions() { - return this.fileStatus.hasRedactions; - } - - get hasRequests() { - return this.fileStatus.hasRequests || this.hasUnappliedSuggestions; - } - - get hasNone() { - return !this.hasRedactions && !this.hasHints && !this.hasRequests; - } - - get lastUpdated() { - return this.fileStatus.lastUpdated; - } - - get numberOfAnalyses() { - return this.fileStatus.numberOfAnalyses; - } - - get dossierId() { - return this.fileStatus.dossierId; - } - - get isExcluded() { - return this.fileStatus.excluded; - } - - get status() { - return this.fileStatus.status === 'REPROCESS' || this.fileStatus.status === 'FULLREPROCESS' ? 'PROCESSING' : this.fileStatus.status; - } - - get numberOfPages() { - return this.fileStatus.numberOfPages; - } - - get numberOfExcludedPages() { - return this.fileStatus.excludedPages?.length || 0; - } - - get uploader() { - return this.fileStatus.uploader; - } - - get isPending() { - return this.status === FileStatus.StatusEnum.UNPROCESSED; - } - - get isProcessing() { - return [ - FileStatus.StatusEnum.REPROCESS, - FileStatus.StatusEnum.FULLREPROCESS, - FileStatus.StatusEnum.OCRPROCESSING, - FileStatus.StatusEnum.INDEXING, - FileStatus.StatusEnum.PROCESSING - ].includes(this.status); - } - - get analysisRequired() { - return this.fileStatus.analysisRequired && !this.fileStatus.excluded; - } - - get statusSort() { - return StatusSorter[this.status]; - } - - get isWorkable() { - return !this.isProcessing && !this.isPending && !this.isError; - } - - get isApproved() { - return this.fileStatus.status === 'APPROVED'; - } - - get isError() { - return this.fileStatus.status === 'ERROR'; - } - - get pages() { + private get _pages() { if (this.fileStatus.status === 'ERROR') { return -1; } return this.fileStatus.numberOfPages ? this.fileStatus.numberOfPages : 0; } - get isApprovedOrUnderApproval() { - return this.status === 'APPROVED' || this.status === 'UNDER_APPROVAL'; - } - - get isUnassigned() { - return !this.currentReviewer; - } - - get isUnderReview() { - return this.fileStatus.status === 'UNDER_REVIEW'; - } - - get isUnderApproval() { - return this.fileStatus.status === 'UNDER_APPROVAL'; - } - - get canApprove() { - return this.status === 'UNDER_REVIEW' || this.status === 'UNDER_APPROVAL'; - } - - get cacheIdentifier() { - return btoa(this.fileStatus.lastUploaded + this.fileStatus.lastOCRTime); - } - - get excludedPages(): number[] { - return this.fileStatus.excludedPages; + private get _status(): FileStatus.StatusEnum { + return this.fileStatus.status === FileStatus.StatusEnum.REPROCESS || this.fileStatus.status === FileStatus.StatusEnum.FULLREPROCESS + ? FileStatus.StatusEnum.PROCESSING + : this.fileStatus.status; } } diff --git a/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.html b/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.html index 255cfba5a..18ad21167 100644 --- a/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.html +++ b/apps/red-ui/src/app/modules/admin/components/dossier-template-actions/dossier-template-actions.component.html @@ -1,7 +1,7 @@
diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index f962aacb5..d90dfa51c 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -144,7 +144,7 @@ export class DossierOverviewScreenComponent extends ListingComponent