+
imple
tableColumnConfigs: readonly TableColumnConfig[];
displayedInFileListAttributes: IFileAttributeConfig[] = [];
displayedAttributes: IFileAttributeConfig[] = [];
- readonly workflowConfig: WorkflowConfig;
+ readonly listingMode$ = this.configService.listingMode$.pipe(
+ tap(() => this._computeAllFilters()),
+ shareLast(),
+ );
readonly dossier$: Observable;
+ readonly files$: Observable;
readonly dossierId: string;
- dossierTemplateId: string;
+ readonly dossierTemplateId: string;
+ readonly workflowConfig: WorkflowConfig;
#currentDossier: Dossier;
@ViewChild('needsWorkFilterTemplate', { read: TemplateRef, static: true })
private readonly _needsWorkFilterTemplate: TemplateRef;
@@ -101,15 +107,12 @@ export class DossierOverviewScreenComponent extends ListingComponent 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 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 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 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);