Merge branch 'release-3.988.0'

This commit is contained in:
Dan Percic 2023-03-16 19:26:55 +02:00
commit e67bfdf659

View File

@ -4,7 +4,7 @@ import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { hasFormChanged, IqserEventTarget } from '../utils';
import { ConfirmOptions } from '.';
import { ConfirmationDialogService } from './confirmation-dialog.service';
import { debounceTime, firstValueFrom, from, fromEvent, mergeMap, Subscription } from 'rxjs';
import { debounceTime, firstValueFrom, fromEvent, merge, Subscription } from 'rxjs';
import { LoadingService } from '../loading';
import { Toaster } from '../services';
import { IconButtonTypes } from '../buttons';
@ -32,23 +32,6 @@ export abstract class BaseDialogComponent implements OnInit, OnDestroy {
protected constructor(protected readonly _dialogRef: MatDialogRef<BaseDialogComponent>, private readonly _isInEditMode?: boolean) {}
ngOnInit() {
this.#subscriptions.add(
this._dialogRef.backdropClick().subscribe(() => {
this.close();
}),
);
this.#subscriptions.add(
from(['keyup', 'input'])
.pipe(
mergeMap(event => fromEvent(window, event)),
debounceTime(0),
tap(() => (this.#hasErrors = !!document.getElementsByClassName('ng-invalid')[0])),
)
.subscribe(),
);
}
get valid(): boolean {
return !this.form || this.form.valid;
}
@ -61,6 +44,17 @@ export abstract class BaseDialogComponent implements OnInit, OnDestroy {
return !this.valid || !this.changed || this.#hasErrors;
}
ngOnInit() {
this.#subscriptions.add(this._dialogRef.backdropClick().subscribe(() => this.close()));
const events = [fromEvent(window, 'keyup'), fromEvent(window, 'input'), this.form?.valueChanges];
const events$ = merge(...events).pipe(
debounceTime(10),
tap(() => (this.#hasErrors = !!document.getElementsByClassName('ng-invalid')[0])),
);
this.#subscriptions.add(events$.subscribe());
}
abstract save(options?: SaveOptions): void;
ngOnDestroy(): void {