@firestitch/form 9.6.4 → 9.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,12 @@
1
- import { OnInit, ChangeDetectorRef } from '@angular/core';
1
+ import { OnInit, ChangeDetectorRef, OnDestroy } from '@angular/core';
2
2
  import { FsFormDirective } from '../../directives/form/form.directive';
3
- export declare class FsFormDialogActionsComponent implements OnInit {
3
+ export declare class FsFormDialogActionsComponent implements OnInit, OnDestroy {
4
4
  private _form;
5
5
  private _cdRef;
6
6
  create: boolean;
7
+ dirty: boolean;
8
+ private _destroy$;
7
9
  constructor(_form: FsFormDirective, _cdRef: ChangeDetectorRef);
8
10
  ngOnInit(): void;
9
- get dirty(): boolean;
11
+ ngOnDestroy(): void;
10
12
  }
@@ -1033,7 +1033,8 @@
1033
1033
  this._form.broadcast('submit', this.ngForm);
1034
1034
  };
1035
1035
  FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
1036
- Object.values(this.ngForm.controls).forEach(function (control) {
1036
+ Object.values(this.ngForm.controls)
1037
+ .forEach(function (control) {
1037
1038
  control.markAsDirty();
1038
1039
  control.markAsTouched();
1039
1040
  control.updateValueAndValidity();
@@ -2372,21 +2373,28 @@
2372
2373
  this._form = _form;
2373
2374
  this._cdRef = _cdRef;
2374
2375
  this.create = false;
2376
+ this.dirty = false;
2377
+ this._destroy$ = new rxjs.Subject();
2375
2378
  }
2376
2379
  FsFormDialogActionsComponent.prototype.ngOnInit = function () {
2377
2380
  var _this = this;
2378
- this._form.ngForm.statusChanges
2381
+ this._form.ngForm.valueChanges
2382
+ .pipe(operators.filter(function () { return (!_this.dirty); }), operators.takeUntil(this._destroy$))
2379
2383
  .subscribe(function () {
2384
+ _this.dirty = _this._form.ngForm.dirty;
2385
+ _this._cdRef.markForCheck();
2386
+ });
2387
+ this._form.submitted
2388
+ .pipe(operators.takeUntil(this._destroy$))
2389
+ .subscribe(function () {
2390
+ _this.dirty = false;
2380
2391
  _this._cdRef.markForCheck();
2381
2392
  });
2382
2393
  };
2383
- Object.defineProperty(FsFormDialogActionsComponent.prototype, "dirty", {
2384
- get: function () {
2385
- return this._form.ngForm.dirty;
2386
- },
2387
- enumerable: true,
2388
- configurable: true
2389
- });
2394
+ FsFormDialogActionsComponent.prototype.ngOnDestroy = function () {
2395
+ this._destroy$.next();
2396
+ this._destroy$.complete();
2397
+ };
2390
2398
  FsFormDialogActionsComponent.ctorParameters = function () { return [
2391
2399
  { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2392
2400
  { type: core.ChangeDetectorRef }