diff --git a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts index 728e6e5a7..dc1910e01 100644 --- a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts @@ -1,9 +1,10 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; import { PrimaryFileAttributeService } from '@services/primary-file-attribute.service'; import { FileAttributes } from '@red/domain'; import { ContextComponent, ScrollableParentView, ScrollableParentViews } from '@iqser/common-ui'; import { FileAttributesConfigMap, FileAttributesService } from '@services/entity-services/file-attributes.service'; import { tap } from 'rxjs/operators'; +import { BehaviorSubject, combineLatestWith, map } from 'rxjs'; interface PartialFile { readonly isError: boolean; @@ -26,10 +27,11 @@ interface FileNameColumnContext { styleUrls: ['./file-name-column.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class FileNameColumnComponent extends ContextComponent implements OnInit { +export class FileNameColumnComponent extends ContextComponent implements OnInit, OnChanges { @Input() file: PartialFile; @Input() dossierTemplateId: string; primaryAttribute: string; + readonly #reloadAttribute = new BehaviorSubject(null); constructor( private readonly _fileAttributeService: FileAttributesService, @@ -41,16 +43,25 @@ export class FileNameColumnComponent extends ContextComponent { this.primaryAttribute = this._primaryFileAttributeService.getPrimaryFileAttributeValue(this.file, this.dossierTemplateId); this._changeDetectorRef.detectChanges(); }), + map(([attributes]) => attributes), ); super._initContext({ fileAttributesConfig: fileAttributesConfig$, }); } + ngOnChanges(changes: SimpleChanges): void { + if (!changes.file) { + return; + } + this.#reloadAttribute.next(null); + } + get scrollableParentView(): ScrollableParentView { return ScrollableParentViews.VIRTUAL_SCROLL; }