remove some .subscribe() to trigger change detector
This commit is contained in:
parent
9af978fcb0
commit
0d9ea7f748
@ -1,3 +1,5 @@
|
||||
<ng-container *ngIf="files$ | async | log"></ng-container>
|
||||
|
||||
<ng-container *ngIf="dossier$ | async as dossier">
|
||||
<section>
|
||||
<redaction-dossier-overview-screen-header
|
||||
@ -8,7 +10,7 @@
|
||||
<div class="overlay-shadow"></div>
|
||||
|
||||
<div class="content-inner">
|
||||
<div *ngIf="configService.listingMode$ | async as mode" [class.extended]="collapsedDetails" class="content-container">
|
||||
<div *ngIf="listingMode$ | async as mode" [class.extended]="collapsedDetails" class="content-container">
|
||||
<iqser-table
|
||||
(noDataAction)="fileInput.click()"
|
||||
*ngIf="mode === listingModes.table"
|
||||
@ -24,7 +26,7 @@
|
||||
[showNoDataButton]="permissionsService.canUploadFiles(dossier)"
|
||||
[tableColumnConfigs]="tableColumnConfigs"
|
||||
[tableItemClasses]="{ disabled: disabledFn, 'last-opened': lastOpenedFn }"
|
||||
helpModeKey="document-list"
|
||||
iqserHelpMode="document-list"
|
||||
></iqser-table>
|
||||
|
||||
<iqser-workflow
|
||||
@ -56,7 +58,7 @@
|
||||
|
||||
<ng-template #bulkActions let-maxWidth="maxWidth">
|
||||
<redaction-dossier-overview-bulk-actions
|
||||
[buttonType]="(configService.listingMode$ | async) === listingModes.table ? circleButtonTypes.dark : circleButtonTypes.primary"
|
||||
[buttonType]="(listingMode$ | async) === listingModes.table ? circleButtonTypes.dark : circleButtonTypes.primary"
|
||||
[dossier]="dossier"
|
||||
[maxWidth]="maxWidth"
|
||||
[selectedFiles]="listingService.selectedEntities$ | async"
|
||||
|
||||
@ -15,7 +15,7 @@ import { FileDropOverlayService } from '@upload-download/services/file-drop-over
|
||||
import { FileUploadModel } from '@upload-download/model/file-upload.model';
|
||||
import { FileUploadService } from '@upload-download/services/file-upload.service';
|
||||
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { merge, Observable } from 'rxjs';
|
||||
import { filter, skip, switchMap, tap } from 'rxjs/operators';
|
||||
import { convertFiles, Files, handleFileDrop } from '@utils/index';
|
||||
import {
|
||||
@ -28,6 +28,7 @@ import {
|
||||
LoadingService,
|
||||
NestedFilter,
|
||||
OnAttach,
|
||||
shareLast,
|
||||
TableColumnConfig,
|
||||
TableComponent,
|
||||
WorkflowConfig,
|
||||
@ -69,10 +70,15 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
tableColumnConfigs: readonly TableColumnConfig<File>[];
|
||||
displayedInFileListAttributes: IFileAttributeConfig[] = [];
|
||||
displayedAttributes: IFileAttributeConfig[] = [];
|
||||
readonly workflowConfig: WorkflowConfig<File, WorkflowFileStatus>;
|
||||
readonly listingMode$ = this.configService.listingMode$.pipe(
|
||||
tap(() => this._computeAllFilters()),
|
||||
shareLast(),
|
||||
);
|
||||
readonly dossier$: Observable<Dossier>;
|
||||
readonly files$: Observable<File[]>;
|
||||
readonly dossierId: string;
|
||||
dossierTemplateId: string;
|
||||
readonly dossierTemplateId: string;
|
||||
readonly workflowConfig: WorkflowConfig<File, WorkflowFileStatus>;
|
||||
#currentDossier: Dossier;
|
||||
@ViewChild('needsWorkFilterTemplate', { read: TemplateRef, static: true })
|
||||
private readonly _needsWorkFilterTemplate: TemplateRef<unknown>;
|
||||
@ -101,15 +107,12 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
) {
|
||||
super(_injector);
|
||||
this.dossierId = _route.snapshot.paramMap.get(DOSSIER_ID);
|
||||
this.dossier$ = this._dossiersService.getEntityChanged$(this.dossierId).pipe(
|
||||
tap(dossier => {
|
||||
this.dossierTemplateId = dossier.dossierTemplateId;
|
||||
this.#currentDossier = this._dossiersService.find(this.dossierId);
|
||||
}),
|
||||
);
|
||||
this.dossier$ = this._dossiersService.getEntityChanged$(this.dossierId).pipe(tap(dossier => (this.#currentDossier = dossier)));
|
||||
this.#currentDossier = this._dossiersService.find(this.dossierId);
|
||||
this.workflowConfig = configService.workflowConfig(this.#currentDossier);
|
||||
this.dossierTemplateId = this.#currentDossier.dossierTemplateId;
|
||||
this.files$ = merge(this.#files$, this.#dossierFilesChange$).pipe(shareLast());
|
||||
this._updateFileAttributes();
|
||||
this.workflowConfig = this.configService.workflowConfig(this.#currentDossier);
|
||||
}
|
||||
|
||||
get checkedRequiredFilters(): NestedFilter[] {
|
||||
@ -120,6 +123,20 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
return this.filterService.getGroup('quickFilters')?.filters.filter(f => !f.required && f.checked);
|
||||
}
|
||||
|
||||
get #files$() {
|
||||
return this._fileMapService.get$(this.dossierId).pipe(
|
||||
tap(files => this.entitiesService.setEntities(files)),
|
||||
tap(() => this._computeAllFilters()),
|
||||
);
|
||||
}
|
||||
|
||||
get #dossierFilesChange$() {
|
||||
return this._dossiersService.dossierFileChanges$.pipe(
|
||||
filter(dossierId => dossierId === this.dossierId),
|
||||
switchMap(dossierId => this._filesService.loadAll(dossierId, this._dossiersService.routerPath)),
|
||||
);
|
||||
}
|
||||
|
||||
disabledFn = (file: File) => file.excluded;
|
||||
|
||||
lastOpenedFn = (file: File) => this._userPreferenceService.getLastOpenedFileForDossier(file.dossierId) === file.id;
|
||||
@ -129,31 +146,12 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
|
||||
this._setRemovableSubscriptions();
|
||||
|
||||
this.addSubscription = this._fileMapService
|
||||
.get$(this.dossierId)
|
||||
.pipe(
|
||||
tap(files => this.entitiesService.setEntities(files)),
|
||||
tap(() => this._computeAllFilters()),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
if (this.#currentDossier.isActive) {
|
||||
this._fileDropOverlayService.initFileDropHandling(this.dossierId);
|
||||
}
|
||||
|
||||
this.addSubscription = this.configService.listingMode$.subscribe(() => {
|
||||
this._computeAllFilters();
|
||||
});
|
||||
|
||||
this.addSubscription = this._dossiersService.dossierFileChanges$
|
||||
.pipe(
|
||||
filter(dossierId => dossierId === this.dossierId),
|
||||
switchMap(dossierId => this._filesService.loadAll(dossierId, this._dossiersService.routerPath)),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
this.addSubscription = this._dossierTemplatesService
|
||||
.getEntityChanged$(this.#currentDossier.dossierTemplateId)
|
||||
.getEntityChanged$(this.dossierTemplateId)
|
||||
.pipe(
|
||||
skip(1),
|
||||
tap(() => {
|
||||
@ -212,8 +210,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
}
|
||||
|
||||
private _updateFileAttributes(): void {
|
||||
this._fileAttributeConfigs =
|
||||
this._fileAttributesService.getFileAttributeConfig(this.#currentDossier.dossierTemplateId)?.fileAttributeConfigs || [];
|
||||
this._fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig(this.dossierTemplateId)?.fileAttributeConfigs || [];
|
||||
this.displayedInFileListAttributes = this._fileAttributeConfigs.filter(config => config.displayedInFileList);
|
||||
this.displayedAttributes = this.displayedInFileListAttributes.filter(c => c.displayedInFileList);
|
||||
this.tableColumnConfigs = this.configService.tableConfig(this.displayedAttributes);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user