RED-3591: stop loading after trying to delete used dossier templates
This commit is contained in:
parent
be0c70fac5
commit
bfea2fe23a
@ -42,8 +42,10 @@ export class DossierTemplateActionsComponent implements OnInit {
|
||||
this._dialogService.openDialog('confirm', $event, null, async () => {
|
||||
this._loadingService.start();
|
||||
|
||||
await firstValueFrom(this._dossierTemplatesService.delete([this.dossierTemplateId]));
|
||||
await this._router.navigate(['main', 'admin']);
|
||||
const success = await firstValueFrom(this._dossierTemplatesService.delete([this.dossierTemplateId]));
|
||||
if (success) {
|
||||
await this._router.navigate(['main', 'admin']);
|
||||
}
|
||||
|
||||
this._loadingService.stop();
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { EntitiesService, List, mapEach, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
|
||||
import { DossierTemplate, IDossierTemplate } from '@red/domain';
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { forkJoin, map, Observable, of, throwError } from 'rxjs';
|
||||
import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { FileAttributesService } from './file-attributes.service';
|
||||
import { catchError, mapTo, switchMap, tap } from 'rxjs/operators';
|
||||
import { DossierTemplateStatsService } from '@services/entity-services/dossier-template-stats.service';
|
||||
@ -49,19 +49,19 @@ export class DossierTemplatesService extends EntitiesService<DossierTemplate, ID
|
||||
);
|
||||
}
|
||||
|
||||
delete(body: List): Observable<unknown> {
|
||||
delete(body: List): Observable<boolean> {
|
||||
const showToast = (error: HttpErrorResponse) => {
|
||||
if (error.status === HttpStatusCode.Conflict) {
|
||||
this._toaster.error(DOSSIER_TEMPLATE_CONFLICT_MSG);
|
||||
} else {
|
||||
this._toaster.error(GENERIC_MSG);
|
||||
}
|
||||
return throwError(() => error);
|
||||
return of(true);
|
||||
};
|
||||
|
||||
return super._post(body, `${this._defaultModelPath}/delete`).pipe(
|
||||
catchError(showToast),
|
||||
switchMap(() => this.loadAll()),
|
||||
switchMap(error => (error ? of(false) : this.loadAll().pipe(mapTo(true)))),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user