added base dialog class
This commit is contained in:
parent
cb1b899520
commit
8cff591c16
19
src/lib/dialog/base-dialog.component.ts
Normal file
19
src/lib/dialog/base-dialog.component.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Directive, HostListener } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { IqserEventTarget } from '@iqser/common-ui';
|
||||
|
||||
@Directive()
|
||||
export abstract class BaseDialogComponent {
|
||||
|
||||
abstract form: FormGroup;
|
||||
abstract get changed(): boolean;
|
||||
abstract save(): void;
|
||||
|
||||
@HostListener('window:keydown.Enter', ['$event'])
|
||||
onEnter(event: KeyboardEvent): void {
|
||||
const node = (event.target as IqserEventTarget).localName;
|
||||
if (this.form.valid && this.changed && node !== 'textarea') {
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user