import { Directive } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { hasFormChanged } from '../utils'; @Directive() export abstract class BaseFormComponent { form!: UntypedFormGroup; initialFormValue!: Record; get changed(): boolean { return hasFormChanged(this.form, this.initialFormValue); } get valid(): boolean { return this.form?.valid; } get disabled(): boolean { return !this.valid || !this.changed; } abstract save(): Promise; }