diff --git a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts index 1142c2e7c..1db7fe6cd 100644 --- a/apps/red-ui/src/app/components/base-screen/base-screen.component.ts +++ b/apps/red-ui/src/app/components/base-screen/base-screen.component.ts @@ -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 diff --git a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts index 9230eabac..1d085a41e 100644 --- a/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/default-colors/default-colors-screen.component.ts @@ -63,7 +63,10 @@ export class DefaultColorsScreenComponent extends ListingComponent imp colorKey: color.key, dossierTemplateId: this._appStateService.activeDossierTemplateId }, - async () => await this._loadColors() + async () => { + await this._loadColors(); + await this._appStateService.refreshDossierTemplate(this._appStateService.activeDossierTemplateId); + } ); } diff --git a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts index 87c060cba..31139185d 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts @@ -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() { diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts index fa6dcba5f..dd942e391 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossier-overview-screen/dossier-overview-screen.component.ts @@ -335,7 +335,7 @@ export class DossierOverviewScreenComponent extends ListingComponent((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] }); }); diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 73145c855..4d1c3d753 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -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(); readonly fileReanalysed$ = new Subject(); + readonly dossierChanged$ = new Subject(); + 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 { - 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[] { + 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) {