sf-crud 13.2.62 → 13.2.63

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.
@@ -2789,19 +2789,30 @@ class ControlComponent {
2789
2789
  }
2790
2790
  }
2791
2791
  sendDependencyValue(data) {
2792
- if (this.control.dependency && this.setDependencyValue) {
2793
- if (typeof (data) !== "object") {
2794
- this.setDependencyValue.emit({ data: data, scope: this.control.dependency.scope });
2795
- }
2796
- else if (typeof (this.control.dependency) === "object") {
2797
- this.setDependencyValue.emit({ data: data[this.control.dependency.value], scope: this.control.dependency.scope });
2798
- }
2799
- else if (Array.isArray(this.control.dependency)) {
2792
+ if (this.control.dependency) {
2793
+ if (Array.isArray(this.control.dependency)) {
2800
2794
  const array = this.control.dependency;
2801
2795
  array.forEach((d) => {
2802
- this.setDependencyValue.emit({ data: data[d.value], scope: d.scope });
2796
+ this.evaluateDependencyValue(data, d.value, d.scope);
2803
2797
  });
2804
2798
  }
2799
+ else {
2800
+ this.evaluateDependencyValue(data, this.control.dependency.value, this.control.dependency.scope);
2801
+ }
2802
+ }
2803
+ }
2804
+ evaluateDependencyValue(data, value, scope) {
2805
+ if ((this.control.subtype === 'dropdown' || this.control.subtype === 'multiselect' || this.control.subtype === 'group') && this.dataFromService.length > 0 && typeof (data) !== "object") {
2806
+ const selectedOption = this.dataFromService.find((item) => item[this.control.config?.optionValue] === data);
2807
+ if (selectedOption) {
2808
+ this.setDependencyValue.emit({ data: selectedOption[value], scope: scope });
2809
+ }
2810
+ }
2811
+ else if (typeof (data) !== "object") {
2812
+ this.setDependencyValue.emit({ data: data, scope: scope });
2813
+ }
2814
+ else {
2815
+ this.setDependencyValue.emit({ data: data[value], scope: scope });
2805
2816
  }
2806
2817
  }
2807
2818
  /**