diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/screen-header/screen-header.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/screen-header/screen-header.component.html index 279dc475f..4a3050292 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/screen-header/screen-header.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/screen-header/screen-header.component.html @@ -12,7 +12,7 @@ > this.sortingService.defaultSort(entities))); sortedEntities$.pipe(take(1)).subscribe(entities => { const fileName = this.dossier.dossierName + '.export.csv'; - saveAsCSV( - fileName, - entities, - [ - 'dossierId', - 'fileId', - 'filename', - 'primaryAttribute', - 'numberOfPages', - 'assignee', - 'workflowStatus', - 'processingStatus', - 'lastUpdated', - 'lastUploaded', - 'lastProcessed', - 'hasHints', - 'hasImages', - 'hasRedactions', - 'hasUpdates', - 'excluded', - ], - fsv => ({ ...fsv, assignee: this._userService.getNameForId(fsv.assignee) }), - ); + const mapper = (file?: IFile) => ({ + ...file, + assignee: this._userService.getNameForId(file.assignee), + primaryAttribute: this._primaryFileAttributeService.getPrimaryFileAttributeValue(file, this.dossier.dossierTemplateId), + }); + const fileFields = [ + 'dossierId', + 'fileId', + 'filename', + 'primaryAttribute', + 'numberOfPages', + 'assignee', + 'workflowStatus', + 'processingStatus', + 'lastUpdated', + 'lastUploaded', + 'lastProcessed', + 'hasHints', + 'hasImages', + 'hasRedactions', + 'hasUpdates', + 'excluded', + ]; + saveAsCSV(fileName, entities, fileFields, mapper); }); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/file-name-column/file-name-column.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/file-name-column/file-name-column.component.ts index dbb49eea1..4b205542e 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/file-name-column/file-name-column.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview/components/table-item/file-name-column/file-name-column.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; import { File } from '@red/domain'; -import { FileAttributesService } from '@services/entity-services/file-attributes.service'; +import { PrimaryFileAttributeService } from '../../../../../../../services/primary-file-attribute.service'; @Component({ selector: 'redaction-file-name-column', @@ -13,19 +13,9 @@ export class FileNameColumnComponent implements OnChanges { @Input() dossierTemplateId: string; primaryAttribute: string; - constructor(private readonly _fileAttributesService: FileAttributesService) {} + constructor(private readonly _primaryFileAttributeService: PrimaryFileAttributeService) {} ngOnChanges() { - const fileAttributesConfig = this._fileAttributesService.getFileAttributeConfig(this.dossierTemplateId); - if (fileAttributesConfig) { - const primary = fileAttributesConfig.fileAttributeConfigs?.find(c => c.primaryAttribute); - if (primary && this.file.fileAttributes?.attributeIdToValue) { - this.primaryAttribute = this.file.fileAttributes?.attributeIdToValue[primary.id]; - } - - if (!this.primaryAttribute) { - this.primaryAttribute = '-'; - } - } + this.primaryAttribute = this._primaryFileAttributeService.getPrimaryFileAttributeValue(this.file, this.dossierTemplateId); } } diff --git a/apps/red-ui/src/app/services/primary-file-attribute.service.ts b/apps/red-ui/src/app/services/primary-file-attribute.service.ts new file mode 100644 index 000000000..5a8acdc18 --- /dev/null +++ b/apps/red-ui/src/app/services/primary-file-attribute.service.ts @@ -0,0 +1,29 @@ +import { Injectable } from '@angular/core'; +import { FileAttributesService } from './entity-services/file-attributes.service'; +import { IFile } from '@red/domain'; + +@Injectable({ + providedIn: 'root', +}) +export class PrimaryFileAttributeService { + constructor(private readonly _fileAttributesService: FileAttributesService) {} + + getPrimaryFileAttributeValue(file: IFile, dossierTemplateId: string) { + const fileAttributesConfig = this._fileAttributesService.getFileAttributeConfig(dossierTemplateId); + + let primaryAttribute; + + if (fileAttributesConfig) { + const primary = fileAttributesConfig.fileAttributeConfigs?.find(c => c.primaryAttribute); + if (primary && file.fileAttributes?.attributeIdToValue) { + primaryAttribute = file.fileAttributes?.attributeIdToValue[primary.id]; + } + } + + if (!primaryAttribute) { + primaryAttribute = '-'; + } + + return primaryAttribute; + } +} diff --git a/libs/red-domain/src/lib/files/file.model.ts b/libs/red-domain/src/lib/files/file.model.ts index aa3f705da..f57b0131a 100644 --- a/libs/red-domain/src/lib/files/file.model.ts +++ b/libs/red-domain/src/lib/files/file.model.ts @@ -39,7 +39,6 @@ export class File extends Entity implements IFile { readonly processingStatus: ProcessingFileStatus; readonly workflowStatus: WorkflowFileStatus; - readonly primaryAttribute?: string; readonly statusSort: number; readonly cacheIdentifier?: string; readonly hintsOnly: boolean; diff --git a/package.json b/package.json index 16bf6f08e..ee649da5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redaction", - "version": "3.181.0", + "version": "3.182.0", "private": true, "license": "MIT", "scripts": { diff --git a/paligo-theme.tar.gz b/paligo-theme.tar.gz index 1e4bf8c68..201430c56 100644 Binary files a/paligo-theme.tar.gz and b/paligo-theme.tar.gz differ