RED-9962 - RM-163: Components values are not updated in the UI until page is refreshed

This commit is contained in:
Valentin Mihai 2024-09-04 16:22:30 +03:00
parent dc66b8a708
commit 1b2f14ec89

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit, signal, ViewChildren } from '@angular/core';
import { Component, effect, Input, OnInit, signal, ViewChildren } from '@angular/core';
import { List } from '@common-ui/utils';
import { IconButtonTypes, LoadingService } from '@iqser/common-ui';
import { ComponentLogEntry, Dictionary, File, IComponentLogEntry, WorkflowFileStatuses } from '@red/domain';
@ -11,6 +11,7 @@ import { map } from 'rxjs/operators';
import { toObservable } from '@angular/core/rxjs-interop';
import { AsyncPipe, NgForOf, NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
@Component({
selector: 'redaction-structured-component-management',
@ -33,7 +34,13 @@ export class StructuredComponentManagementComponent implements OnInit {
private readonly _loadingService: LoadingService,
private readonly _componentLogFilterService: ComponentLogFilterService,
private readonly _filterService: FilterService,
) {}
private readonly _state: FilePreviewStateService,
) {
effect(async () => {
this._state.file();
await this.#loadData();
});
}
get canEdit() {
return this.file.workflowStatus !== WorkflowFileStatuses.APPROVED;
@ -75,7 +82,6 @@ export class StructuredComponentManagementComponent implements OnInit {
}
async #loadData(): Promise<void> {
this._loadingService.start();
const componentLogData = await firstValueFrom(
this._componentLogService.getComponentLogData(
this.file.dossierTemplateId,
@ -86,7 +92,6 @@ export class StructuredComponentManagementComponent implements OnInit {
);
this.#computeFilters(componentLogData);
this.componentLogData.set(componentLogData);
this._loadingService.stop();
}
#computeFilters(componentLogs: ComponentLogEntry[]) {