@firestitch/form 12.4.1 → 12.4.3

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.
@@ -58,6 +58,7 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
58
58
  private _activatedRouteConfig;
59
59
  private _status$;
60
60
  private _destroy$;
61
+ private _confirmed;
61
62
  constructor(ngForm: NgForm, _form: FsForm, _element: ElementRef, _message: FsMessage, _prompt: FsPrompt, _ngZone: NgZone, _dialogRef: MatDialogRef<any>, _drawerRef: DrawerRef<any>, _route: ActivatedRoute);
62
63
  get submitting(): boolean;
63
64
  get validating(): boolean;
@@ -77,7 +78,9 @@ export declare class FsFormDirective implements OnInit, OnDestroy, AfterContentI
77
78
  reset(): void;
78
79
  clear(): void;
79
80
  dirty(): void;
80
- triggerSubmit(): void;
81
+ triggerSubmit(options?: {
82
+ confirmed: boolean;
83
+ }): void;
81
84
  triggerConfirm(): Observable<ConfirmResult>;
82
85
  enable(): void;
83
86
  disable(): void;
@@ -2,4 +2,5 @@ import { NgForm } from '@angular/forms';
2
2
  export interface SubmitEvent {
3
3
  ngForm: NgForm;
4
4
  submitter: string;
5
+ confirmed?: boolean;
5
6
  }
@@ -3,4 +3,5 @@ export interface SubmittedEvent {
3
3
  ngForm: NgForm;
4
4
  submitter: string;
5
5
  response: any;
6
+ confirmed?: boolean;
6
7
  }
@@ -419,7 +419,7 @@
419
419
  observer.complete();
420
420
  });
421
421
  form.ngForm.control.markAsPristine();
422
- form.ngForm.ngSubmit.emit();
422
+ form.triggerSubmit({ confirmed: true });
423
423
  }
424
424
  }, function (error) {
425
425
  observer.next(exports.ConfirmResult.Review);
@@ -615,6 +615,7 @@
615
615
  this._snapshot = {};
616
616
  this._status$ = new rxjs.BehaviorSubject(exports.FormStatus.Valid);
617
617
  this._destroy$ = new rxjs.Subject();
618
+ this._confirmed = false;
618
619
  }
619
620
  Object.defineProperty(FsFormDirective.prototype, "submitting", {
620
621
  get: function () {
@@ -754,8 +755,9 @@
754
755
  this.ngForm.form.markAsDirty();
755
756
  this._updateDirtySubmitButtons();
756
757
  };
757
- FsFormDirective.prototype.triggerSubmit = function () {
758
- this.ngForm.ngSubmit.next();
758
+ FsFormDirective.prototype.triggerSubmit = function (options) {
759
+ this._confirmed = options === null || options === void 0 ? void 0 : options.confirmed;
760
+ this.ngForm.ngSubmit.emit();
759
761
  };
760
762
  FsFormDirective.prototype.triggerConfirm = function () {
761
763
  var _this = this;
@@ -788,13 +790,18 @@
788
790
  .ngSubmit
789
791
  .pipe(operators.tap(function (event) {
790
792
  event === null || event === void 0 ? void 0 : event.preventDefault();
791
- }), operators.filter(function () {
793
+ }), operators.map(function (event) {
794
+ return { event: event, confirmed: _this._confirmed };
795
+ }), operators.tap(function () { return _this._confirmed = false; }), operators.filter(function () {
792
796
  return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
793
797
  .includes(_this._status$.getValue());
794
- }), operators.tap(function () { return _this._broadcasValidatingEvents(); }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function () { return _this._waitUntilStatusPending(); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.tap(function () { return _this._disableButtons(); }), operators.mergeMap(function () {
795
- return _this.ngForm.status === 'INVALID'
796
- ? _this._formInvalidState$
797
- : _this._formValidState$;
798
+ }), operators.tap(function () { return _this._broadcasValidatingEvents(); }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function (data) { return _this._waitUntilStatusPending()
799
+ .pipe(operators.mapTo(data)); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.tap(function () { return _this._disableButtons(); }), operators.mergeMap(function (data) {
800
+ if (_this.ngForm.status === 'INVALID') {
801
+ return _this._formInvalidState$;
802
+ }
803
+ return _this._formValidState$
804
+ .pipe(operators.map(function (submitEvent) { return (Object.assign(Object.assign({}, submitEvent), { confirmed: data.confirmed })); }));
798
805
  }), operators.catchError(function (e, source$) {
799
806
  _this._handleError(e);
800
807
  return source$;