@elite.framework/ng.core 1.0.13 → 1.0.14

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.
@@ -3750,9 +3750,6 @@ class GenericSelectorTypeComponent extends FieldType {
3750
3750
  }
3751
3751
  else {
3752
3752
  this.formControl.setValue(val?.[vf] ?? null);
3753
- // if(this.props.change){
3754
- // this.props.change(this.field,{item:this.selectedItem});
3755
- // }
3756
3753
  }
3757
3754
  }
3758
3755
  ngOnInit() {
@@ -3784,9 +3781,27 @@ class GenericSelectorTypeComponent extends FieldType {
3784
3781
  .subscribe(() => {
3785
3782
  // This tap operator is a good place to run side effects
3786
3783
  // like calling your change handler after a value changes.
3787
- this.selectedItem = this.formControl.value;
3784
+ // this.selectedItem = this.formControl.value;
3788
3785
  if (this.props.change) {
3789
- this.props.change(this.field, { item: this.selectedItem });
3786
+ if (to['offline']) {
3787
+ if (to['offlineDataFn']) {
3788
+ this._offlineList = to['offlineDataFn']();
3789
+ this.initOfflineSelection(false);
3790
+ }
3791
+ else if (to['offlineItems$']) {
3792
+ to['offlineItems$'].subscribe((list) => {
3793
+ this._offlineList = list;
3794
+ this.initOfflineSelection(false);
3795
+ });
3796
+ }
3797
+ else {
3798
+ this._offlineList = to['offlineItems'] || [];
3799
+ this.initOfflineSelection(false);
3800
+ }
3801
+ }
3802
+ else {
3803
+ this.initOnlineSelection(false);
3804
+ }
3790
3805
  }
3791
3806
  });
3792
3807
  }
@@ -3796,7 +3811,7 @@ class GenericSelectorTypeComponent extends FieldType {
3796
3811
  this.valueChangeSubscription.unsubscribe();
3797
3812
  }
3798
3813
  }
3799
- initOfflineSelection() {
3814
+ initOfflineSelection(withSetValue = true) {
3800
3815
  const val = this.formControl.value;
3801
3816
  const vf = this.to['valueField'] || 'id';
3802
3817
  if (val == null)
@@ -3807,11 +3822,18 @@ class GenericSelectorTypeComponent extends FieldType {
3807
3822
  else {
3808
3823
  this.selectedItem = this._offlineList.find(item => item[vf] === val);
3809
3824
  }
3810
- this.formControl.setValue(this.to['multiple']
3811
- ? this.selectedItem.map((c) => c[vf])
3812
- : this.selectedItem?.[vf]);
3825
+ if (withSetValue == true) {
3826
+ this.formControl.setValue(this.to['multiple']
3827
+ ? this.selectedItem.map((c) => c[vf])
3828
+ : this.selectedItem?.[vf]);
3829
+ }
3830
+ else {
3831
+ if (this.props.change) {
3832
+ this.props.change(this.field, { item: this.selectedItem });
3833
+ }
3834
+ }
3813
3835
  }
3814
- initOnlineSelection() {
3836
+ initOnlineSelection(withSetValue = true) {
3815
3837
  var d = this.selectedItem;
3816
3838
  const fullModel = this.model;
3817
3839
  const val = this.formControl.value;
@@ -3826,7 +3848,14 @@ class GenericSelectorTypeComponent extends FieldType {
3826
3848
  .pipe(finalize$1(() => (this.loading = false)))
3827
3849
  .subscribe(items => {
3828
3850
  this.selectedItem = items;
3829
- this.formControl.setValue(items.map((c) => c[vf]));
3851
+ if (withSetValue == true) {
3852
+ this.formControl.setValue(items.map((c) => c[vf]));
3853
+ }
3854
+ else {
3855
+ if (this.props.change) {
3856
+ this.props.change(this.field, { item: this.selectedItem });
3857
+ }
3858
+ }
3830
3859
  });
3831
3860
  }
3832
3861
  else {
@@ -3836,7 +3865,14 @@ class GenericSelectorTypeComponent extends FieldType {
3836
3865
  .subscribe((item) => {
3837
3866
  this.selectedItem = item;
3838
3867
  // debugger
3839
- this.formControl.setValue(item?.[vf]);
3868
+ if (withSetValue == true) {
3869
+ this.formControl.setValue(item?.[vf]);
3870
+ }
3871
+ else {
3872
+ if (this.props.change) {
3873
+ this.props.change(this.field, { item: this.selectedItem });
3874
+ }
3875
+ }
3840
3876
  });
3841
3877
  }
3842
3878
  }