mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1308: #3256 Abholfachremissionsvorschau Create Toas with Dialog Text or Fallback Me...
#3256 Abholfachremissionsvorschau Create Toas with Dialog Text or Fallback Message if Dialog is not available
This commit is contained in:
committed by
Lorenz Hilpert
parent
fa43a08831
commit
9a45823bdb
@@ -8,6 +8,7 @@ import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
|
||||
import { first, map, shareReplay, takeUntil } from 'rxjs/operators';
|
||||
import { GoodsInRemissionPreviewStore } from './goods-in-remission-preview.store';
|
||||
import { Config } from '@core/config';
|
||||
import { ToastService } from '@core/toast';
|
||||
|
||||
@Component({
|
||||
selector: 'page-goods-in-remission-preview',
|
||||
@@ -54,7 +55,8 @@ export class GoodsInRemissionPreviewComponent implements OnInit, OnDestroy {
|
||||
private _route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private _modal: UiModalService,
|
||||
private _config: Config
|
||||
private _config: Config,
|
||||
private _toast: ToastService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -148,7 +150,14 @@ export class GoodsInRemissionPreviewComponent implements OnInit, OnDestroy {
|
||||
this.changeActionLoader$.next(true);
|
||||
|
||||
try {
|
||||
await this._store.createRemissionFromPreview().pipe(first()).toPromise();
|
||||
const response = await this._store.createRemissionFromPreview().pipe(first()).toPromise();
|
||||
|
||||
if (!response?.dialog) {
|
||||
this._toast.create({
|
||||
text: response?.message,
|
||||
});
|
||||
}
|
||||
|
||||
await this.navigateToRemission();
|
||||
} catch (error) {
|
||||
this._modal.open({
|
||||
|
||||
@@ -5,10 +5,11 @@ import { UiDialogModalComponent } from './dialog-modal.component';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { DialogModel } from './dialog.model';
|
||||
import { ToastService } from '@core/toast';
|
||||
|
||||
@Injectable()
|
||||
export class OpenDialogInterceptor implements HttpInterceptor {
|
||||
constructor(private _modal: UiModalService) {}
|
||||
constructor(private _modal: UiModalService, private _toast: ToastService) {}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
return next.handle(req).pipe(
|
||||
@@ -17,17 +18,30 @@ export class OpenDialogInterceptor implements HttpInterceptor {
|
||||
if (response?.body?.dialog?.area === 'dialog') {
|
||||
this.openDialog(response.body.dialog);
|
||||
}
|
||||
if (response?.body?.dialog?.area === 'toast') {
|
||||
this.createToast(response.body.dialog);
|
||||
}
|
||||
}
|
||||
}),
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
if (error?.error?.dialog?.area === 'dialog') {
|
||||
this.openDialog(error.error.dialog);
|
||||
}
|
||||
if (error?.error?.dialog?.area === 'toast') {
|
||||
this.createToast(error.error.dialog);
|
||||
}
|
||||
return throwError(error);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
createToast(dialog: DialogModel) {
|
||||
this._toast.create({
|
||||
title: dialog.title,
|
||||
text: dialog.content,
|
||||
});
|
||||
}
|
||||
|
||||
openDialog(model: DialogModel) {
|
||||
this._modal.open({
|
||||
content: UiDialogModalComponent,
|
||||
|
||||
Reference in New Issue
Block a user