try fix files list change detection

This commit is contained in:
Dan Percic 2022-03-29 12:29:10 +03:00
parent c404f876a8
commit eb101e7f9f
3 changed files with 12 additions and 28 deletions

View File

@ -1,6 +1,4 @@
<ng-container *ngIf="files$ | async | log"></ng-container>
<ng-container *ngIf="dossier$ | async as dossier">
<ng-container *ngIf="(files$ | async) && dossier$ | async as dossier">
<section>
<redaction-dossier-overview-screen-header
(upload)="fileInput.click()"
@ -73,6 +71,10 @@
[file]="file"
></redaction-table-item>
</ng-template>
<ng-template #workflowItemTemplate let-entity="entity">
<redaction-workflow-item [displayedAttributes]="displayedAttributes" [dossier]="dossier" [file]="entity"></redaction-workflow-item>
</ng-template>
</ng-container>
<ng-template #needsWorkFilterTemplate let-filter="filter">
@ -80,11 +82,3 @@
</ng-template>
<input #fileInput (change)="uploadFiles($event.target['files'])" class="file-upload-input" multiple="true" type="file" />
<ng-template #workflowItemTemplate let-entity="entity">
<redaction-workflow-item
[displayedAttributes]="displayedAttributes"
[dossier]="dossier$ | async"
[file]="entity"
></redaction-workflow-item>
</ng-template>

View File

@ -1,15 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
ElementRef,
forwardRef,
HostListener,
Injector,
OnDestroy,
OnInit,
TemplateRef,
ViewChild,
} from '@angular/core';
import { Component, ElementRef, forwardRef, HostListener, Injector, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { Dossier, DossierAttributeWithValue, File, IFileAttributeConfig, WorkflowFileStatus } from '@red/domain';
import { FileDropOverlayService } from '@upload-download/services/file-drop-overlay.service';
import { FileUploadModel } from '@upload-download/model/file-upload.model';
@ -47,6 +36,7 @@ import { DOSSIER_ID } from '@utils/constants';
import { BulkActionsService } from '../services/bulk-actions.service';
import { DossiersService } from '@services/dossiers/dossiers.service';
import { dossiersServiceProvider } from '@services/entity-services/dossiers.service.provider';
import { NGXLogger } from 'ngx-logger';
@Component({
templateUrl: './dossier-overview-screen.component.html',
@ -58,7 +48,6 @@ import { dossiersServiceProvider } from '@services/entity-services/dossiers.serv
{ provide: ListingComponent, useExisting: forwardRef(() => DossierOverviewScreenComponent) },
dossiersServiceProvider,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DossierOverviewScreenComponent extends ListingComponent<File> implements OnInit, OnDestroy, OnAttach {
readonly listingModes = ListingModes;
@ -102,13 +91,14 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
private readonly _fileMapService: FilesMapService,
private readonly _errorService: ErrorService,
private readonly _route: ActivatedRoute,
private readonly _logger: NGXLogger,
readonly permissionsService: PermissionsService,
readonly configService: ConfigService,
) {
super(_injector);
this.dossierId = _route.snapshot.paramMap.get(DOSSIER_ID);
this.dossier$ = this._dossiersService.getEntityChanged$(this.dossierId).pipe(tap(dossier => (this.#currentDossier = dossier)));
this.#currentDossier = this._dossiersService.find(this.dossierId);
this.dossier$ = _dossiersService.getEntityChanged$(this.dossierId).pipe(tap(dossier => (this.#currentDossier = dossier)));
this.#currentDossier = _dossiersService.find(this.dossierId);
this.workflowConfig = configService.workflowConfig(this.#currentDossier);
this.dossierTemplateId = this.#currentDossier.dossierTemplateId;
this.files$ = merge(this.#files$, this.#dossierFilesChange$).pipe(shareLast());
@ -163,7 +153,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
try {
this.dossierAttributes = await this._dossierAttributesService.getWithValues(this.#currentDossier);
} catch (e) {
console.log('Error from dossier overview screen: ', e);
this._logger.error('[DOSSIER ATTRIBUTES] Error: ', e);
}
this._loadingService.stop();

@ -1 +1 @@
Subproject commit aab7e8c0b1b4822f31777ffc8a38febdfc2ea041
Subproject commit 320c3d3f4a68cef5a7387ed93af7fcc28e6a9dde