skip requests for entries, show loading indicator when action finished
This commit is contained in:
parent
44ccbc4a6c
commit
def0d17121
@ -35,14 +35,12 @@
|
||||
|
||||
<redaction-circle-button
|
||||
(action)="openDeleteDictionariesDialog($event)"
|
||||
*ngIf="areSomeEntitiesSelected && !loading && permissionsService.isAdmin()"
|
||||
*ngIf="areSomeEntitiesSelected && permissionsService.isAdmin()"
|
||||
icon="red:trash"
|
||||
tooltip="dictionary-listing.bulk.delete"
|
||||
type="dark-bg"
|
||||
></redaction-circle-button>
|
||||
|
||||
<mat-spinner *ngIf="loading" diameter="15"></mat-spinner>
|
||||
|
||||
<div class="attributes-actions-container">
|
||||
<redaction-input-with-action
|
||||
[form]="searchForm"
|
||||
@ -190,7 +188,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<redaction-full-page-loading-indicator
|
||||
[displayed]="!viewReady"
|
||||
></redaction-full-page-loading-indicator>
|
||||
|
||||
@ -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<TypeValueWrapper>
|
||||
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user