sf-crud 13.2.59 → 13.2.61

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