RED-3592: Dictionary add/edit loading indicator & success message
This commit is contained in:
parent
526df97eae
commit
1811bb59b8
@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, Inject, Injector } from '@angular/c
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { firstValueFrom, Observable } from 'rxjs';
|
||||
import { BaseDialogComponent, shareDistinctLast, Toaster } from '@iqser/common-ui';
|
||||
import { BaseDialogComponent, LoadingService, shareDistinctLast, Toaster } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { toSnakeCase } from '@utils/functions';
|
||||
@ -36,6 +36,7 @@ export class AddEditDictionaryDialogComponent extends BaseDialogComponent {
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
protected readonly _injector: Injector,
|
||||
protected readonly _dialogRef: MatDialogRef<AddEditDictionaryDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA)
|
||||
@ -64,18 +65,24 @@ export class AddEditDictionaryDialogComponent extends BaseDialogComponent {
|
||||
}
|
||||
|
||||
async save(): Promise<void> {
|
||||
this._loadingService.start();
|
||||
const dictionary = this._formToObject();
|
||||
const dossierTemplateId = this._data.dossierTemplateId;
|
||||
|
||||
if (this.dictionary) {
|
||||
// edit mode
|
||||
await firstValueFrom(this._dictionaryService.updateDictionary(dictionary, dossierTemplateId, dictionary.type));
|
||||
} else {
|
||||
// create mode
|
||||
await firstValueFrom(this._dictionaryService.addDictionary({ ...dictionary, dossierTemplateId }));
|
||||
}
|
||||
try {
|
||||
if (this.dictionary) {
|
||||
// edit mode
|
||||
await firstValueFrom(this._dictionaryService.updateDictionary(dictionary, dossierTemplateId, dictionary.type));
|
||||
this._toaster.success(_('add-edit-dictionary.success.edit'));
|
||||
} else {
|
||||
// create mode
|
||||
await firstValueFrom(this._dictionaryService.addDictionary({ ...dictionary, dossierTemplateId }));
|
||||
this._toaster.success(_('add-edit-dictionary.success.create'));
|
||||
}
|
||||
this._dialogRef.close(true);
|
||||
} catch (e) {}
|
||||
|
||||
this._dialogRef.close(true);
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
private _getForm(dictionary: Dictionary): FormGroup {
|
||||
|
||||
@ -56,6 +56,10 @@
|
||||
"technical-name": "Technischer Name"
|
||||
},
|
||||
"save": "Wörterbuch speichern",
|
||||
"success": {
|
||||
"create": "",
|
||||
"edit": ""
|
||||
},
|
||||
"title": "{type, select, edit{Wörterbuch {name} bearbeiten} create{Wörterbuch erstellen} other{}}"
|
||||
},
|
||||
"add-edit-dossier-attribute": {
|
||||
|
||||
@ -56,6 +56,10 @@
|
||||
"technical-name": "Technical Name"
|
||||
},
|
||||
"save": "Save Dictionary",
|
||||
"success": {
|
||||
"create": "Dictionary added!",
|
||||
"edit": "Dictionary updated!"
|
||||
},
|
||||
"title": "{type, select, edit{Edit {name}} create{Create} other{}} Dictionary"
|
||||
},
|
||||
"add-edit-dossier-attribute": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user