@elite.framework/ng.core 1.0.10 → 1.0.12

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.
@@ -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 (this.props.change) {
3756
- this.props.change(this.field, { item: this.selectedItem });
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,22 @@ 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
+ .subscribe(() => {
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
+ }
3793
+ // Remember to unsubscribe to prevent memory leaks!
3794
+ ngOnDestroy() {
3795
+ if (this.valueChangeSubscription) {
3796
+ this.valueChangeSubscription.unsubscribe();
3797
+ }
3785
3798
  }
3786
3799
  initOfflineSelection() {
3787
3800
  const val = this.formControl.value;