@elite.framework/ng.core 1.0.13 → 1.0.15

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.
@@ -3729,6 +3729,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
3729
3729
  class GenericSelectorTypeComponent extends FieldType {
3730
3730
  svc;
3731
3731
  injector;
3732
+ cdr;
3732
3733
  autoComp;
3733
3734
  options_ = [];
3734
3735
  selectedItem;
@@ -3737,10 +3738,11 @@ class GenericSelectorTypeComponent extends FieldType {
3737
3738
  api;
3738
3739
  dialog;
3739
3740
  valueChangeSubscription; // Add a subscription to manage the observable
3740
- constructor(svc, injector) {
3741
+ constructor(svc, injector, cdr) {
3741
3742
  super();
3742
3743
  this.svc = svc;
3743
3744
  this.injector = injector;
3745
+ this.cdr = cdr;
3744
3746
  }
3745
3747
  onSelectionChange(val) {
3746
3748
  this.selectedItem = val;
@@ -3750,9 +3752,6 @@ class GenericSelectorTypeComponent extends FieldType {
3750
3752
  }
3751
3753
  else {
3752
3754
  this.formControl.setValue(val?.[vf] ?? null);
3753
- // if(this.props.change){
3754
- // this.props.change(this.field,{item:this.selectedItem});
3755
- // }
3756
3755
  }
3757
3756
  }
3758
3757
  ngOnInit() {
@@ -3784,9 +3783,27 @@ class GenericSelectorTypeComponent extends FieldType {
3784
3783
  .subscribe(() => {
3785
3784
  // This tap operator is a good place to run side effects
3786
3785
  // like calling your change handler after a value changes.
3787
- this.selectedItem = this.formControl.value;
3786
+ // this.selectedItem = this.formControl.value;
3788
3787
  if (this.props.change) {
3789
- this.props.change(this.field, { item: this.selectedItem });
3788
+ if (to['offline']) {
3789
+ if (to['offlineDataFn']) {
3790
+ this._offlineList = to['offlineDataFn']();
3791
+ this.initOfflineSelection(false);
3792
+ }
3793
+ else if (to['offlineItems$']) {
3794
+ to['offlineItems$'].subscribe((list) => {
3795
+ this._offlineList = list;
3796
+ this.initOfflineSelection(false);
3797
+ });
3798
+ }
3799
+ else {
3800
+ this._offlineList = to['offlineItems'] || [];
3801
+ this.initOfflineSelection(false);
3802
+ }
3803
+ }
3804
+ else {
3805
+ this.initOnlineSelection(false);
3806
+ }
3790
3807
  }
3791
3808
  });
3792
3809
  }
@@ -3796,7 +3813,7 @@ class GenericSelectorTypeComponent extends FieldType {
3796
3813
  this.valueChangeSubscription.unsubscribe();
3797
3814
  }
3798
3815
  }
3799
- initOfflineSelection() {
3816
+ initOfflineSelection(withSetValue = true) {
3800
3817
  const val = this.formControl.value;
3801
3818
  const vf = this.to['valueField'] || 'id';
3802
3819
  if (val == null)
@@ -3807,11 +3824,19 @@ class GenericSelectorTypeComponent extends FieldType {
3807
3824
  else {
3808
3825
  this.selectedItem = this._offlineList.find(item => item[vf] === val);
3809
3826
  }
3810
- this.formControl.setValue(this.to['multiple']
3811
- ? this.selectedItem.map((c) => c[vf])
3812
- : this.selectedItem?.[vf]);
3827
+ if (withSetValue == true) {
3828
+ this.formControl.setValue(this.to['multiple']
3829
+ ? this.selectedItem.map((c) => c[vf])
3830
+ : this.selectedItem?.[vf]);
3831
+ }
3832
+ else {
3833
+ if (this.props.change) {
3834
+ this.props.change(this.field, { item: this.selectedItem });
3835
+ this.cdr.detectChanges();
3836
+ }
3837
+ }
3813
3838
  }
3814
- initOnlineSelection() {
3839
+ initOnlineSelection(withSetValue = true) {
3815
3840
  var d = this.selectedItem;
3816
3841
  const fullModel = this.model;
3817
3842
  const val = this.formControl.value;
@@ -3826,7 +3851,15 @@ class GenericSelectorTypeComponent extends FieldType {
3826
3851
  .pipe(finalize$1(() => (this.loading = false)))
3827
3852
  .subscribe(items => {
3828
3853
  this.selectedItem = items;
3829
- this.formControl.setValue(items.map((c) => c[vf]));
3854
+ if (withSetValue == true) {
3855
+ this.formControl.setValue(items.map((c) => c[vf]));
3856
+ }
3857
+ else {
3858
+ if (this.props.change) {
3859
+ this.props.change(this.field, { item: this.selectedItem });
3860
+ this.cdr.detectChanges();
3861
+ }
3862
+ }
3830
3863
  });
3831
3864
  }
3832
3865
  else {
@@ -3836,7 +3869,15 @@ class GenericSelectorTypeComponent extends FieldType {
3836
3869
  .subscribe((item) => {
3837
3870
  this.selectedItem = item;
3838
3871
  // debugger
3839
- this.formControl.setValue(item?.[vf]);
3872
+ if (withSetValue == true) {
3873
+ this.formControl.setValue(item?.[vf]);
3874
+ }
3875
+ else {
3876
+ if (this.props.change) {
3877
+ this.props.change(this.field, { item: this.selectedItem });
3878
+ this.cdr.detectChanges();
3879
+ }
3880
+ }
3840
3881
  });
3841
3882
  }
3842
3883
  }
@@ -3909,7 +3950,7 @@ class GenericSelectorTypeComponent extends FieldType {
3909
3950
  return Array.isArray(this.selectedItem) &&
3910
3951
  this.selectedItem.some((sel) => sel[vf] === item[vf]);
3911
3952
  }
3912
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GenericSelectorTypeComponent, deps: [{ token: BaseService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
3953
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GenericSelectorTypeComponent, deps: [{ token: BaseService }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
3913
3954
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: GenericSelectorTypeComponent, isStandalone: true, selector: "formly-generic-selector", providers: [DialogService, BaseService], viewQueries: [{ propertyName: "autoComp", first: true, predicate: ["autoComp"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
3914
3955
  <p-autoComplete
3915
3956
  #autoComp
@@ -3991,7 +4032,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
3991
4032
  CheckboxModule
3992
4033
  ]
3993
4034
  }]
3994
- }], ctorParameters: () => [{ type: BaseService }, { type: i0.Injector }], propDecorators: { autoComp: [{
4035
+ }], ctorParameters: () => [{ type: BaseService }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }], propDecorators: { autoComp: [{
3995
4036
  type: ViewChild,
3996
4037
  args: ['autoComp']
3997
4038
  }] } });