osl-base-extended 2.0.30 → 2.0.32

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.
@@ -2703,7 +2703,7 @@ class DynamicForm {
2703
2703
  this.loadApiDatasources();
2704
2704
  }
2705
2705
  ngOnChanges(changes) {
2706
- if (changes['elements']) {
2706
+ if (changes['elements'] || changes['model']) {
2707
2707
  this.loadApiDatasources();
2708
2708
  }
2709
2709
  }
@@ -2720,6 +2720,8 @@ class DynamicForm {
2720
2720
  const allReady = elem.dependsOn.every(k => this.model?.[k] != null);
2721
2721
  if (!allReady)
2722
2722
  continue;
2723
+ if (elem.datasource?.length)
2724
+ continue;
2723
2725
  }
2724
2726
  elem.loadingIf = () => true;
2725
2727
  const data = await this.datasourceCache.load(elem.apiService, elem.apiMethod, elem.apiBody ? elem.apiBody(this.model) : null);
@@ -2753,6 +2755,7 @@ class DynamicForm {
2753
2755
  elem.change(this.model, undefined, selectedObj);
2754
2756
  }
2755
2757
  onFieldChange(elem, value) {
2758
+ this.model[elem.key] = value;
2756
2759
  if (elem.change)
2757
2760
  this.onSelectChange(elem, value);
2758
2761
  this._refreshDependents(elem.key);
@@ -2760,8 +2763,21 @@ class DynamicForm {
2760
2763
  async _refreshDependents(changedKey) {
2761
2764
  const dependents = this._flatElements().filter(e => e.dependsOn?.includes(changedKey));
2762
2765
  for (const dep of dependents) {
2763
- const body = dep.apiBody ? dep.apiBody(this.model) : undefined;
2764
2766
  let valueCleared = false;
2767
+ // If any parent dependency is now null, clear field + datasource without API call
2768
+ const anyDepNull = dep.dependsOn.some(k => this.model[k] == null);
2769
+ if (anyDepNull) {
2770
+ if (this.model[dep.key] != null) {
2771
+ this.model[dep.key] = null;
2772
+ valueCleared = true;
2773
+ }
2774
+ dep.datasource = [];
2775
+ this.cdr.markForCheck();
2776
+ if (valueCleared)
2777
+ await this._refreshDependents(dep.key);
2778
+ continue;
2779
+ }
2780
+ const body = dep.apiBody ? dep.apiBody(this.model) : undefined;
2765
2781
  if (dep.searchType !== 'Api' && dep.apiService && dep.apiMethod) {
2766
2782
  dep.loadingIf = () => true;
2767
2783
  this.cdr.markForCheck();