Pull request #399: RED-6129, fix title attribute not being updated from CSV file.
Merge in RED/ui from RED-6129 to master * commit '0396cc5ff71318995b4f0b9f5f68a8c475365610': RED-6129, fix title attribute not being updated from CSV file.
This commit is contained in:
commit
7dfd1801df
@ -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<FileNameColumnContext> implements OnInit {
|
||||
export class FileNameColumnComponent extends ContextComponent<FileNameColumnContext> 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<FileNameColumnCont
|
||||
|
||||
ngOnInit(): void {
|
||||
const fileAttributesConfig$ = this._fileAttributeService.fileAttributesConfig$.pipe(
|
||||
combineLatestWith(this.#reloadAttribute),
|
||||
tap(() => {
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user