cat-qw-lib 0.43.16 → 0.43.18

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.
@@ -600,9 +600,6 @@ class FormStateService {
600
600
  this.formChangesSubject$ = new BehaviorSubject(false);
601
601
  this.isFormNavigating$ = new BehaviorSubject(false);
602
602
  }
603
- setFormChanges(hasChanges) {
604
- this.formChangesSubject$.next(hasChanges);
605
- }
606
603
  setIsFormNavigating(isNavigation) {
607
604
  this.isFormNavigating$.next(isNavigation);
608
605
  }
@@ -612,10 +609,13 @@ class FormStateService {
612
609
  selectIsFormNavigating() {
613
610
  return this.isFormNavigating$.asObservable();
614
611
  }
615
- getSUnsavedChanges() {
612
+ setIsFormSaved(hasChanges) {
613
+ this.formChangesSubject$.next(hasChanges);
614
+ }
615
+ getIsFormSaved() {
616
616
  return this.formChangesSubject$.getValue();
617
617
  }
618
- selectSUnsavedChanges() {
618
+ selectIsFormSaved() {
619
619
  return this.formChangesSubject$.asObservable();
620
620
  }
621
621
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: FormStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -666,12 +666,10 @@ class BaseControlComponent {
666
666
  }
667
667
  });
668
668
  this.formStateService.selectIsFormNavigating().subscribe((res) => {
669
+ console.log("1 isFormNavigating =>", res);
669
670
  if (res) {
670
- this.formStateService.selectSUnsavedChanges().subscribe((res) => {
671
- if (res) {
672
- this.checkUnsavedChanges();
673
- }
674
- });
671
+ console.log("2 call checkUnSaved =>", res);
672
+ this.checkUnsavedChanges();
675
673
  }
676
674
  });
677
675
  }
@@ -709,10 +707,23 @@ class BaseControlComponent {
709
707
  return this.record[this.attributeModel.name];
710
708
  }
711
709
  checkUnsavedChanges() {
712
- const hasChanges = JSON.stringify(this.initialRecord) !== JSON.stringify(this.record);
713
- if (this.formStateService && hasChanges) {
714
- this.formStateService.setFormChanges(hasChanges);
715
- }
710
+ this.formStateService.selectIsFormSaved().subscribe((res) => {
711
+ console.log("3=> isFormSaved", res);
712
+ if (res === false) {
713
+ console.log("4=> if false", res);
714
+ const hasChanges = JSON.stringify(this.initialRecord) !== JSON.stringify(this.record);
715
+ if (this.formStateService && hasChanges) {
716
+ console.log("5=> false", hasChanges);
717
+ this.formStateService.setIsFormSaved(hasChanges);
718
+ }
719
+ }
720
+ else {
721
+ if (this.formStateService) {
722
+ console.log("6=> else");
723
+ this.formStateService.setIsFormSaved(false);
724
+ }
725
+ }
726
+ });
716
727
  }
717
728
  ngOnDestroy() {
718
729
  this.destroy$.next();
@@ -1389,7 +1400,8 @@ class BaseFormComponent {
1389
1400
  this.record = {};
1390
1401
  this.baseStore?.setIsApiValidated(null);
1391
1402
  if (this.formStateService) {
1392
- this.formStateService.setFormChanges(false);
1403
+ console.log("Update");
1404
+ this.formStateService.setIsFormSaved(true);
1393
1405
  }
1394
1406
  this.onFormNavigate.emit(response);
1395
1407
  },
@@ -1407,7 +1419,8 @@ class BaseFormComponent {
1407
1419
  this.record = {};
1408
1420
  this.baseStore?.setIsApiValidated(null);
1409
1421
  if (this.formStateService) {
1410
- this.formStateService.setIsFormNavigating(false);
1422
+ console.log("Add");
1423
+ this.formStateService.setIsFormSaved(true);
1411
1424
  }
1412
1425
  this.onFormNavigate.emit(response);
1413
1426
  },