checked how many mat dialogs are opened on 'esc' event in BaseDialog instead of 'waitingForConfirmation' flag
This commit is contained in:
parent
174b239f26
commit
8f8ce778bd
@ -1,5 +1,5 @@
|
||||
import { Directive, HostListener, Injector, OnInit } from '@angular/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { AutoUnsubscribe, hasFormChanged, IqserEventTarget } from '../utils';
|
||||
import { ConfirmOptions } from '../misc';
|
||||
@ -25,8 +25,8 @@ export interface SaveOptions {
|
||||
export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnInit {
|
||||
form!: FormGroup;
|
||||
initialFormValue;
|
||||
protected readonly _dialogService: ConfirmationDialogService = this._injector.get(ConfirmationDialogService);
|
||||
protected _waitingForConfirmation = false;
|
||||
private readonly _dialogService: ConfirmationDialogService = this._injector.get(ConfirmationDialogService);
|
||||
private readonly _dialog: MatDialog = this._injector.get(MatDialog);
|
||||
|
||||
constructor(protected readonly _injector: Injector, protected readonly _dialogRef: MatDialogRef<BaseDialogComponent>) {
|
||||
super();
|
||||
@ -62,7 +62,6 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
||||
this._dialogRef.close();
|
||||
}
|
||||
}
|
||||
this._waitingForConfirmation = false;
|
||||
});
|
||||
} else {
|
||||
this._dialogRef.close();
|
||||
@ -79,13 +78,12 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
||||
|
||||
@HostListener('window:keydown.Escape', ['$event'])
|
||||
onEscape(): void {
|
||||
if (!this._waitingForConfirmation) {
|
||||
if (this._dialog.openDialogs.length === 1) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected _openConfirmDialog() {
|
||||
this._waitingForConfirmation = true;
|
||||
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
|
||||
return firstValueFrom(dialogRef.afterClosed());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user