mmhglobal-dynamicform 2.3.0 → 2.3.2

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.
@@ -11750,22 +11750,24 @@ class ZudfComponent extends ContainerFieldBase {
11750
11750
  this.subscription = this.componentService.componentLoaded$.subscribe(() => {
11751
11751
  // All components have finished loading
11752
11752
  const zudfGroup = this.group[this.componentScopeName];
11753
- zudfGroup['linkedComponent'].forEach(item => {
11754
- const linkedComponentSegments = item.value.split('_');
11755
- const parentComponentName = linkedComponentSegments.slice(0, -1).join('_') + '_' + item.linkedComponent;
11756
- const parentComponent = ZComponentHelper.getComponentByValue(this.group, parentComponentName);
11757
- const childComponent = ZComponentHelper.getComponentByValue(this.group, item.value);
11758
- if (parentComponent && childComponent) {
11759
- const originalSelectOptions = childComponent.data['originalSelectOptions'] ?? Object.assign([], childComponent.data.SelectOptions);
11760
- const filteredSelectionOptions = originalSelectOptions.filter(option => option.parentExpression == zudfGroup.zModel[parentComponentName]);
11761
- // Manually patch the component form control value
11762
- const zudfForm = zudfGroup.form;
11763
- const componentFormControl = zudfForm.controls[item.value];
11764
- childComponent.setSelectOption(filteredSelectionOptions);
11765
- componentFormControl.patchValue(zudfGroup.zModel[item.value]);
11766
- this.cdr.detectChanges();
11767
- }
11768
- });
11753
+ if (zudfGroup['linkedComponent']) {
11754
+ zudfGroup['linkedComponent'].forEach(item => {
11755
+ const linkedComponentSegments = item.value.split('_');
11756
+ const parentComponentName = linkedComponentSegments.slice(0, 2).join('_') + '_' + item.linkedComponent;
11757
+ const parentComponent = ZComponentHelper.getComponentByValue(this.group, parentComponentName);
11758
+ const childComponent = ZComponentHelper.getComponentByValue(this.group, item.value);
11759
+ if (parentComponent && childComponent) {
11760
+ const originalSelectOptions = childComponent.data['originalSelectOptions'] ?? Object.assign([], childComponent.data.SelectOptions);
11761
+ const filteredSelectionOptions = originalSelectOptions.filter(option => option.parentExpression == zudfGroup.zModel[parentComponentName]);
11762
+ // Manually patch the component form control value
11763
+ const zudfForm = zudfGroup.form;
11764
+ const componentFormControl = zudfForm.controls[item.value];
11765
+ childComponent.setSelectOption(filteredSelectionOptions);
11766
+ componentFormControl.patchValue(zudfGroup.zModel[item.value]);
11767
+ this.cdr.detectChanges();
11768
+ }
11769
+ });
11770
+ }
11769
11771
  // To consider: Trigger the "onchange" event or perform any other necessary actions here
11770
11772
  });
11771
11773
  }