dynamic filters update, fixed colors and dossier action updates without refresh
This commit is contained in:
parent
bdc8a61831
commit
f89a798efb
@ -12,7 +12,6 @@ import { SpotlightSearchAction } from '@components/spotlight-search/spotlight-se
|
||||
import { SpotlightSearchDialogData } from '@components/spotlight-search/spotlight-search-dialog-data';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { distinctUntilChanged, filter, map, startWith } from 'rxjs/operators';
|
||||
import { HelpModeService } from '@iqser/common-ui';
|
||||
|
||||
interface MenuItem {
|
||||
readonly name: string;
|
||||
@ -69,7 +68,6 @@ export class BaseScreenComponent {
|
||||
readonly userPreferenceService: UserPreferenceService,
|
||||
readonly titleService: Title,
|
||||
readonly fileDownloadService: FileDownloadService,
|
||||
readonly helpModeService: HelpModeService,
|
||||
private readonly _router: Router,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _dialog: MatDialog
|
||||
|
||||
@ -63,7 +63,10 @@ export class DefaultColorsScreenComponent extends ListingComponent<ListItem> imp
|
||||
colorKey: color.key,
|
||||
dossierTemplateId: this._appStateService.activeDossierTemplateId
|
||||
},
|
||||
async () => await this._loadColors()
|
||||
async () => {
|
||||
await this._loadColors();
|
||||
await this._appStateService.refreshDossierTemplate(this._appStateService.activeDossierTemplateId);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -100,6 +100,10 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD
|
||||
this.fileStatus = fileStatus;
|
||||
this._setup();
|
||||
});
|
||||
|
||||
this.addSubscription = this.appStateService.dossierChanged$.subscribe(() => {
|
||||
this._setup();
|
||||
});
|
||||
}
|
||||
|
||||
toggleViewDocumentInfo() {
|
||||
|
||||
@ -335,7 +335,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
|
||||
}
|
||||
let filterValue = file.fileAttributes?.attributeIdToValue[config.id];
|
||||
if (!filterValue) {
|
||||
filterValue = this._translateService.instant('filters.empty');
|
||||
filterValue = '-';
|
||||
file.fileAttributes.attributeIdToValue[config.id] = '-';
|
||||
}
|
||||
filters.add(filterValue);
|
||||
@ -403,9 +403,9 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
|
||||
icon: 'red:template',
|
||||
filters: [...filterValue].map<NestedFilter>((value: string) => ({
|
||||
key: value,
|
||||
label: value
|
||||
label: value === '-' ? this._translateService.instant('filters.empty') : value
|
||||
})),
|
||||
checker: (input: FileStatusWrapper, filter: NestedFilter) => filter.label === input.fileAttributes.attributeIdToValue[id]
|
||||
checker: (input: FileStatusWrapper, filter: NestedFilter) => filter.key === input.fileAttributes.attributeIdToValue[id]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
import { Event, NavigationEnd, ResolveStart, Router } from '@angular/router';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { forkJoin, Observable, of, Subject } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import { FALLBACK_COLOR, hexToRgb } from '@utils/functions';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { DossierWrapper } from './model/dossier.wrapper';
|
||||
@ -43,6 +43,8 @@ export interface AppState {
|
||||
export class AppStateService {
|
||||
readonly fileChanged$ = new Subject<FileStatusWrapper>();
|
||||
readonly fileReanalysed$ = new Subject<FileStatusWrapper>();
|
||||
readonly dossierChanged$ = new Subject<DossierWrapper>();
|
||||
|
||||
private _appState: AppState;
|
||||
|
||||
constructor(
|
||||
@ -360,6 +362,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
this._appState.dossiers.push(foundDossier);
|
||||
this.dossierChanged$.next(foundDossier);
|
||||
return foundDossier;
|
||||
} catch (error) {
|
||||
this._toaster.error(
|
||||
@ -407,27 +410,27 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
async loadDictionaryData(): Promise<void> {
|
||||
const obj = {};
|
||||
const observables = [];
|
||||
|
||||
for (const dossierTemplate of this.dossierTemplates) {
|
||||
obj[dossierTemplate.dossierTemplateId] = {};
|
||||
observables.push(
|
||||
...this._getDictionaryDataForDossierTemplateObservables(
|
||||
dossierTemplate.dossierTemplateId,
|
||||
obj[dossierTemplate.dossierTemplateId]
|
||||
)
|
||||
);
|
||||
observables.push(this._getDictionaryDataForDossierTemplateObservables(dossierTemplate.dossierTemplateId));
|
||||
}
|
||||
const result = await forkJoin(observables).toPromise();
|
||||
|
||||
const dictionaryData = {};
|
||||
for (let i = 0; i < this.dossierTemplates.length; i++) {
|
||||
dictionaryData[this.dossierTemplates[i].dossierTemplateId] = result[i];
|
||||
}
|
||||
|
||||
await forkJoin(observables).toPromise();
|
||||
this._dictionaryData = obj;
|
||||
this._dictionaryData = dictionaryData;
|
||||
}
|
||||
|
||||
private _getDictionaryDataForDossierTemplateObservables(
|
||||
dossierTemplateId: string,
|
||||
dictionaryData: { [key: string]: any }
|
||||
): Observable<any>[] {
|
||||
async refreshDossierTemplate(dossierTemplateId: string) {
|
||||
this._dictionaryData[dossierTemplateId] = await this._getDictionaryDataForDossierTemplateObservables(dossierTemplateId).toPromise();
|
||||
}
|
||||
|
||||
private _getDictionaryDataForDossierTemplateObservables(dossierTemplateId: string): Observable<{ [key: string]: any }> {
|
||||
const dictionaryData: { [key: string]: any } = {};
|
||||
|
||||
const typeObs = this._dictionaryControllerService.getAllTypes(dossierTemplateId).pipe(
|
||||
tap(typesResponse => {
|
||||
for (const type of typesResponse.types) {
|
||||
@ -656,7 +659,7 @@ export class AppStateService {
|
||||
})
|
||||
);
|
||||
|
||||
return [typeObs, colorsObs];
|
||||
return forkJoin([typeObs, colorsObs]).pipe(map(() => dictionaryData));
|
||||
}
|
||||
|
||||
private async _updateLastActiveFileForDossier(dossierId: string, fileId: string) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user