|
|
@ -20,6 +20,7 @@ import { |
|
|
HttpEvent, |
|
|
HttpEvent, |
|
|
HttpHandler, |
|
|
HttpHandler, |
|
|
HttpInterceptor, |
|
|
HttpInterceptor, |
|
|
|
|
|
HttpParams, |
|
|
HttpRequest, |
|
|
HttpRequest, |
|
|
HttpStatusCode |
|
|
HttpStatusCode |
|
|
} from '@angular/common/http'; |
|
|
} from '@angular/common/http'; |
|
|
@ -32,6 +33,8 @@ import { |
|
|
import { HasId } from '@shared/models/base-data'; |
|
|
import { HasId } from '@shared/models/base-data'; |
|
|
import { HasVersion } from '@shared/models/entity.models'; |
|
|
import { HasVersion } from '@shared/models/entity.models'; |
|
|
import { getInterceptorConfig } from './interceptor.util'; |
|
|
import { getInterceptorConfig } from './interceptor.util'; |
|
|
|
|
|
import { isDefined } from '@core/utils'; |
|
|
|
|
|
import { InterceptorConfig } from '@core/interceptors/interceptor-config'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
export class EntityConflictInterceptor implements HttpInterceptor { |
|
|
export class EntityConflictInterceptor implements HttpInterceptor { |
|
|
@ -67,8 +70,12 @@ export class EntityConflictInterceptor implements HttpInterceptor { |
|
|
|
|
|
|
|
|
return this.openConflictDialog(request.body, error.error.message).pipe( |
|
|
return this.openConflictDialog(request.body, error.error.message).pipe( |
|
|
switchMap(result => { |
|
|
switchMap(result => { |
|
|
if (result) { |
|
|
if (isDefined(result)) { |
|
|
return next.handle(this.updateRequestVersion(request)); |
|
|
if (result) { |
|
|
|
|
|
return next.handle(this.updateRequestVersion(request)); |
|
|
|
|
|
} |
|
|
|
|
|
(request.params as HttpParams & { interceptorConfig: InterceptorConfig }).interceptorConfig.ignoreErrors = true; |
|
|
|
|
|
return next.handle(request); |
|
|
} |
|
|
} |
|
|
return of(null); |
|
|
return of(null); |
|
|
}) |
|
|
}) |
|
|
@ -82,7 +89,9 @@ export class EntityConflictInterceptor implements HttpInterceptor { |
|
|
|
|
|
|
|
|
private openConflictDialog(entity: unknown & HasId & HasVersion, message: string): Observable<boolean> { |
|
|
private openConflictDialog(entity: unknown & HasId & HasVersion, message: string): Observable<boolean> { |
|
|
const dialogRef = this.dialog.open(EntityConflictDialogComponent, { |
|
|
const dialogRef = this.dialog.open(EntityConflictDialogComponent, { |
|
|
data: { message, entity } |
|
|
disableClose: true, |
|
|
|
|
|
data: { message, entity }, |
|
|
|
|
|
panelClass: ['tb-fullscreen-dialog'], |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return dialogRef.afterClosed(); |
|
|
return dialogRef.afterClosed(); |
|
|
|