cat-qw-lib 0.43.47 → 0.43.49
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.
package/fesm2022/cat-qw-lib.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, Input, Output, Injectable,
|
|
2
|
+
import { EventEmitter, Component, Input, Output, Injectable, ViewChild, ViewEncapsulation, HostListener, Pipe, Directive, NgModule, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i3$1 from '@angular/forms';
|
|
@@ -23,7 +23,7 @@ import * as i3$2 from 'primeng/checkbox';
|
|
|
23
23
|
import { CheckboxModule } from 'primeng/checkbox';
|
|
24
24
|
import { EntityStore, StoreConfig, QueryEntity } from '@datorama/akita';
|
|
25
25
|
import { __decorate } from 'tslib';
|
|
26
|
-
import { BehaviorSubject,
|
|
26
|
+
import { BehaviorSubject, Subject, takeUntil, firstValueFrom, of, tap as tap$1, map, debounceTime, distinctUntilChanged, catchError, Subscription } from 'rxjs';
|
|
27
27
|
import { DragDropModule } from 'primeng/dragdrop';
|
|
28
28
|
import * as i5 from 'primeng/confirmdialog';
|
|
29
29
|
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
|
@@ -664,72 +664,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImpor
|
|
|
664
664
|
}]
|
|
665
665
|
}], ctorParameters: () => [] });
|
|
666
666
|
|
|
667
|
-
class CheckUnsavedChangesService {
|
|
668
|
-
formStateService;
|
|
669
|
-
sanitizedInitialRecord;
|
|
670
|
-
sanitizedCurrentRecord;
|
|
671
|
-
constructor(formStateService) {
|
|
672
|
-
this.formStateService = formStateService;
|
|
673
|
-
}
|
|
674
|
-
// checkUnsavedChanges(initialRecord: any, currentRecord: any, isBrowserEvent?: boolean) {
|
|
675
|
-
// this.sanitizedInitialRecord = this.normalizeRecord(initialRecord);
|
|
676
|
-
// this.sanitizedCurrentRecord = this.normalizeRecord(currentRecord);
|
|
677
|
-
// console.log('1 sanitizedInitialRecord', this.sanitizedInitialRecord);
|
|
678
|
-
// console.log('2 sanitizedCurrentRecord', this.sanitizedCurrentRecord);
|
|
679
|
-
// const hasChanges = JSON.stringify(this.sanitizedInitialRecord) !== JSON.stringify(this.sanitizedCurrentRecord);
|
|
680
|
-
// if (isBrowserEvent && hasChanges) {
|
|
681
|
-
// this.formStateService.setShowBroswerConfirmDialog(true);
|
|
682
|
-
// } else {
|
|
683
|
-
// this.formStateService.setShowBroswerConfirmDialog(false);
|
|
684
|
-
// }
|
|
685
|
-
// this.formStateService.selectIsFormSaved().subscribe((res: boolean) => {
|
|
686
|
-
// if (res) {
|
|
687
|
-
// this.formStateService.setShowConfirmation(false);
|
|
688
|
-
// console.log('3 isFormSaved');
|
|
689
|
-
// } else {
|
|
690
|
-
// console.log(hasChanges ? '4 not saved but hasChanges' : '5 not saved and not hasChanges');
|
|
691
|
-
// this.formStateService.setShowConfirmation(hasChanges);
|
|
692
|
-
// }
|
|
693
|
-
// });
|
|
694
|
-
// }
|
|
695
|
-
// private normalizeRecord(record: any): Record<string, any> {
|
|
696
|
-
// if (!record) return {};
|
|
697
|
-
// return Object.keys(record).reduce((acc, key) => {
|
|
698
|
-
// let value = record[key];
|
|
699
|
-
// acc[key] = value === undefined || value === SHARED.EMPTY ? undefined : value;
|
|
700
|
-
// return acc;
|
|
701
|
-
// }, {} as Record<string, any>);
|
|
702
|
-
// }
|
|
703
|
-
checkUnsavedChanges(initialRecord, currentRecord, isBrowserEvent) {
|
|
704
|
-
const sanitizedInitialRecord = this.normalizeRecord(initialRecord);
|
|
705
|
-
const sanitizedCurrentRecord = this.normalizeRecord(currentRecord);
|
|
706
|
-
console.log('1 sanitizedInitialRecord', sanitizedInitialRecord);
|
|
707
|
-
console.log('2 sanitizedCurrentRecord', sanitizedCurrentRecord);
|
|
708
|
-
const hasChanges = JSON.stringify(sanitizedInitialRecord) !== JSON.stringify(sanitizedCurrentRecord);
|
|
709
|
-
if (isBrowserEvent) {
|
|
710
|
-
console.log("3 for browser event");
|
|
711
|
-
this.formStateService.setShowBroswerConfirmDialog(hasChanges);
|
|
712
|
-
}
|
|
713
|
-
this.formStateService.selectIsFormSaved().pipe(take(1)).subscribe((isFormSaved) => {
|
|
714
|
-
this.formStateService.setShowConfirmation(!isFormSaved && hasChanges);
|
|
715
|
-
console.log(isFormSaved ? '3 isFormSaved' : hasChanges ? '4 not saved but hasChanges' : '5 not saved and not hasChanges');
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
normalizeRecord(record) {
|
|
719
|
-
if (!record)
|
|
720
|
-
return {};
|
|
721
|
-
return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, value === undefined || value === SHARED.EMPTY ? undefined : value]));
|
|
722
|
-
}
|
|
723
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: CheckUnsavedChangesService, deps: [{ token: FormStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
724
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: CheckUnsavedChangesService, providedIn: 'root' });
|
|
725
|
-
}
|
|
726
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: CheckUnsavedChangesService, decorators: [{
|
|
727
|
-
type: Injectable,
|
|
728
|
-
args: [{
|
|
729
|
-
providedIn: 'root'
|
|
730
|
-
}]
|
|
731
|
-
}], ctorParameters: () => [{ type: FormStateService }] });
|
|
732
|
-
|
|
733
667
|
class BaseControlComponent {
|
|
734
668
|
baseStore;
|
|
735
669
|
baseQuery;
|
|
@@ -750,7 +684,6 @@ class BaseControlComponent {
|
|
|
750
684
|
textboxField;
|
|
751
685
|
dropdown;
|
|
752
686
|
textArea;
|
|
753
|
-
unsavedChangesService = inject(CheckUnsavedChangesService);
|
|
754
687
|
initialRecord = {};
|
|
755
688
|
static allAttributes = [];
|
|
756
689
|
query;
|
|
@@ -831,9 +764,47 @@ class BaseControlComponent {
|
|
|
831
764
|
checkUnsavedChanges(isBrowserEvent) {
|
|
832
765
|
this.formStateService.selectInitialRecord().subscribe((res) => {
|
|
833
766
|
if (res) {
|
|
834
|
-
this.
|
|
767
|
+
this.sanitizedInitialRecord = this.normalizeRecord(res);
|
|
768
|
+
this.sanitizedCurrentRecord = this.normalizeRecord(this.record);
|
|
769
|
+
console.log("1 sanitizedInitialRecord", this.sanitizedInitialRecord);
|
|
770
|
+
console.log("2 sanitizedCurrentRecord", this.sanitizedCurrentRecord);
|
|
835
771
|
}
|
|
836
772
|
});
|
|
773
|
+
const hasChanges = JSON.stringify(this.sanitizedInitialRecord) !== JSON.stringify(this.sanitizedCurrentRecord);
|
|
774
|
+
if (isBrowserEvent && hasChanges) {
|
|
775
|
+
this.formStateService.setShowBroswerConfirmDialog(true);
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
this.formStateService.setShowBroswerConfirmDialog(false);
|
|
779
|
+
}
|
|
780
|
+
this.formStateService.selectIsFormSaved().subscribe((res) => {
|
|
781
|
+
if (res) {
|
|
782
|
+
this.formStateService.setShowConfirmation(false);
|
|
783
|
+
console.log("3 isFormSaved");
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
if (!res && hasChanges) {
|
|
787
|
+
console.log("4 not saved but hasChanges");
|
|
788
|
+
this.formStateService.setShowConfirmation(true);
|
|
789
|
+
}
|
|
790
|
+
if (!res && !hasChanges) {
|
|
791
|
+
console.log("5 not saved and not hasChanges");
|
|
792
|
+
this.formStateService.setShowConfirmation(false);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
normalizeRecord(record) {
|
|
798
|
+
if (!record)
|
|
799
|
+
return {};
|
|
800
|
+
return Object.keys(record).reduce((acc, key) => {
|
|
801
|
+
let value = record[key];
|
|
802
|
+
if (value === undefined || value === SHARED.EMPTY) {
|
|
803
|
+
value = undefined;
|
|
804
|
+
}
|
|
805
|
+
acc[key] = value;
|
|
806
|
+
return acc;
|
|
807
|
+
}, {});
|
|
837
808
|
}
|
|
838
809
|
ngOnDestroy() {
|
|
839
810
|
this.destroy$.next();
|