diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html index 082f7bbc9..a7372ec7a 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.html @@ -35,14 +35,12 @@ - -
- - diff --git a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts index 97fbdd3cd..c9630a1fd 100644 --- a/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/dictionary-listing/dictionary-listing-screen.component.ts @@ -10,6 +10,7 @@ import { AdminDialogService } from '../../services/admin-dialog.service'; import { BaseListingComponent } from '@shared/base/base-listing.component'; import { TypeValueWrapper } from '../../../../models/file/type-value.wrapper'; import { TranslateService } from '@ngx-translate/core'; +import { LoadingService } from '../../../../services/loading.service'; @Component({ selector: 'redaction-dictionary-listing-screen', @@ -20,9 +21,7 @@ export class DictionaryListingScreenComponent extends BaseListingComponent implements OnInit { - viewReady = false; chartData: DoughnutChartConfig[] = []; - loading = false; protected readonly _searchKey = 'label'; protected readonly _selectionKey = 'type'; protected readonly _sortKey = 'dictionary-listing'; @@ -32,14 +31,14 @@ export class DictionaryListingScreenComponent private readonly _dictionaryControllerService: DictionaryControllerService, private readonly _activatedRoute: ActivatedRoute, private readonly _appStateService: AppStateService, + private readonly _loadingService: LoadingService, private readonly _translateService: TranslateService, readonly permissionsService: PermissionsService, protected readonly _injector: Injector ) { super(_injector); - this._appStateService.activateDossierTemplate( - _activatedRoute.snapshot.params.dossierTemplateId - ); + _loadingService.start(); + _appStateService.activateDossierTemplate(_activatedRoute.snapshot.params.dossierTemplateId); } get tableHeader(): string { @@ -59,10 +58,10 @@ export class DictionaryListingScreenComponent this._appStateService.activeDossierTemplateId, async () => { this.selectedEntitiesIds = []; - this.loading = true; + this._loadingService.start(); await this._appStateService.loadDictionaryData(); - this._loadDictionaryData(); - this.loading = false; + this._loadDictionaryData(false); + this._loadingService.stop(); } ); } @@ -74,19 +73,31 @@ export class DictionaryListingScreenComponent this._appStateService.activeDossierTemplateId, async newDictionary => { if (newDictionary) { + this._loadingService.start(); await this._appStateService.loadDictionaryData(); - this._loadDictionaryData(); + this._loadDictionaryData(false); + this._loadingService.stop(); } } ); } - private _loadDictionaryData() { + private _loadDictionaryData(loadEntries = true): void { const appStateDictionaryData = this._appStateService.dictionaryData[this._appStateService.activeDossierTemplateId]; - this.allEntities = Object.values(appStateDictionaryData).filter(d => !d.virtual); + const entities = Object.values(appStateDictionaryData).filter(d => !d.virtual); + + if (!loadEntries) + this.allEntities = entities.map(dict => { + dict.entries = this.allEntities.find(d => d.type === dict.type)?.entries || []; + return dict; + }); + else this.allEntities = entities; + this.displayedEntities = [...this.allEntities]; + if (!loadEntries) return; + const dataObs = this.allEntities.map(dict => this._dictionaryControllerService .getDictionaryForType(this._appStateService.activeDossierTemplateId, dict.type) @@ -108,7 +119,7 @@ export class DictionaryListingScreenComponent private _calculateData(): void { this.chartData = this.allEntities.map(dict => this._toChartConfig(dict)); this.chartData.sort((a, b) => (a.label < b.label ? -1 : 1)); - this.viewReady = true; + this._loadingService.stop(); } private _toChartConfig(dict: TypeValueWrapper): DoughnutChartConfig {