@elite.framework/ng.core 1.0.10 → 1.0.11
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.
|
@@ -47,7 +47,7 @@ import * as i1$7 from 'primeng/splitbutton';
|
|
|
47
47
|
import { SplitButtonModule } from 'primeng/splitbutton';
|
|
48
48
|
import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
|
|
49
49
|
import { InputGroupModule } from 'primeng/inputgroup';
|
|
50
|
-
import { finalize as finalize$1 } from 'rxjs/operators';
|
|
50
|
+
import { finalize as finalize$1, tap } from 'rxjs/operators';
|
|
51
51
|
import { FormlyPrimeNGModule, withFormlyPrimeNG } from '@ngx-formly/primeng';
|
|
52
52
|
import { ProgressSpinnerModule } from 'primeng/progressspinner';
|
|
53
53
|
import { MessageModule } from 'primeng/message';
|
|
@@ -3736,6 +3736,7 @@ class GenericSelectorTypeComponent extends FieldType {
|
|
|
3736
3736
|
_offlineList = [];
|
|
3737
3737
|
api;
|
|
3738
3738
|
dialog;
|
|
3739
|
+
valueChangeSubscription; // Add a subscription to manage the observable
|
|
3739
3740
|
constructor(svc, injector) {
|
|
3740
3741
|
super();
|
|
3741
3742
|
this.svc = svc;
|
|
@@ -3746,19 +3747,15 @@ class GenericSelectorTypeComponent extends FieldType {
|
|
|
3746
3747
|
const vf = this.to['valueField'] || 'id';
|
|
3747
3748
|
if (this.to['multiple']) {
|
|
3748
3749
|
this.formControl.setValue(Array.isArray(val) ? val.map((c) => c[vf]) : []);
|
|
3749
|
-
if (this.props.change) {
|
|
3750
|
-
this.props.change(this.field, { item: this.selectedItem });
|
|
3751
|
-
}
|
|
3752
3750
|
}
|
|
3753
3751
|
else {
|
|
3754
|
-
this.formControl.setValue(val?.[vf] ?? null);
|
|
3755
|
-
if
|
|
3756
|
-
|
|
3757
|
-
}
|
|
3752
|
+
// this.formControl.setValue(val?.[vf] ?? null);
|
|
3753
|
+
// if(this.props.change){
|
|
3754
|
+
// this.props.change(this.field,{item:this.selectedItem});
|
|
3755
|
+
// }
|
|
3758
3756
|
}
|
|
3759
3757
|
}
|
|
3760
3758
|
ngOnInit() {
|
|
3761
|
-
// this.api = this.injector.get(BaseService);
|
|
3762
3759
|
this.api = this.svc;
|
|
3763
3760
|
this.dialog = this.injector.get(DialogService);
|
|
3764
3761
|
const to = this.props;
|
|
@@ -3782,6 +3779,23 @@ class GenericSelectorTypeComponent extends FieldType {
|
|
|
3782
3779
|
else {
|
|
3783
3780
|
this.initOnlineSelection();
|
|
3784
3781
|
}
|
|
3782
|
+
// Subscribe to formControl value changes
|
|
3783
|
+
this.valueChangeSubscription = this.formControl.valueChanges
|
|
3784
|
+
.pipe(tap(() => {
|
|
3785
|
+
// This tap operator is a good place to run side effects
|
|
3786
|
+
// like calling your change handler after a value changes.
|
|
3787
|
+
this.selectedItem = this.formControl.value;
|
|
3788
|
+
if (this.props.change) {
|
|
3789
|
+
this.props.change(this.field, { item: this.selectedItem });
|
|
3790
|
+
}
|
|
3791
|
+
}))
|
|
3792
|
+
.subscribe();
|
|
3793
|
+
}
|
|
3794
|
+
// Remember to unsubscribe to prevent memory leaks!
|
|
3795
|
+
ngOnDestroy() {
|
|
3796
|
+
if (this.valueChangeSubscription) {
|
|
3797
|
+
this.valueChangeSubscription.unsubscribe();
|
|
3798
|
+
}
|
|
3785
3799
|
}
|
|
3786
3800
|
initOfflineSelection() {
|
|
3787
3801
|
const val = this.formControl.value;
|