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 { 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 { FormGroup } from '@angular/forms';
|
||||||
import { AutoUnsubscribe, hasFormChanged, IqserEventTarget } from '../utils';
|
import { AutoUnsubscribe, hasFormChanged, IqserEventTarget } from '../utils';
|
||||||
import { ConfirmOptions } from '../misc';
|
import { ConfirmOptions } from '../misc';
|
||||||
@ -25,8 +25,8 @@ export interface SaveOptions {
|
|||||||
export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnInit {
|
export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnInit {
|
||||||
form!: FormGroup;
|
form!: FormGroup;
|
||||||
initialFormValue;
|
initialFormValue;
|
||||||
protected readonly _dialogService: ConfirmationDialogService = this._injector.get(ConfirmationDialogService);
|
private readonly _dialogService: ConfirmationDialogService = this._injector.get(ConfirmationDialogService);
|
||||||
protected _waitingForConfirmation = false;
|
private readonly _dialog: MatDialog = this._injector.get(MatDialog);
|
||||||
|
|
||||||
constructor(protected readonly _injector: Injector, protected readonly _dialogRef: MatDialogRef<BaseDialogComponent>) {
|
constructor(protected readonly _injector: Injector, protected readonly _dialogRef: MatDialogRef<BaseDialogComponent>) {
|
||||||
super();
|
super();
|
||||||
@ -62,7 +62,6 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
|||||||
this._dialogRef.close();
|
this._dialogRef.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._waitingForConfirmation = false;
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._dialogRef.close();
|
this._dialogRef.close();
|
||||||
@ -79,13 +78,12 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
|||||||
|
|
||||||
@HostListener('window:keydown.Escape', ['$event'])
|
@HostListener('window:keydown.Escape', ['$event'])
|
||||||
onEscape(): void {
|
onEscape(): void {
|
||||||
if (!this._waitingForConfirmation) {
|
if (this._dialog.openDialogs.length === 1) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _openConfirmDialog() {
|
protected _openConfirmDialog() {
|
||||||
this._waitingForConfirmation = true;
|
|
||||||
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
|
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
|
||||||
return firstValueFrom(dialogRef.afterClosed());
|
return firstValueFrom(dialogRef.afterClosed());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user