onshore-forms 0.0.50 → 0.0.52

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.
@@ -163,17 +163,23 @@ class OnshoreFormsService {
163
163
  if (subitem.type == OnshoreFormTemplateType.subform) {
164
164
  if (item.subformArray) {
165
165
  formControls[subitem.name] = new FormArray([]);
166
+ formControls[subitem.name].setParent(formControls[subitem.name]);
167
+ this.subscribeNestedFormArray(formControls[subitem.name]);
166
168
  }
167
169
  if (item.subformObject) {
168
170
  formControls[subitem.name] = new FormGroup({});
171
+ this.subscribeNestedFormGroup(formControls[subitem.name]);
169
172
  }
170
173
  }
171
174
  else {
172
175
  const defaultValue = defaultValues?.find(value => value.name === subitem.name)?.value;
176
+ if (defaultValue)
177
+ subitem.default = defaultValue.value;
173
178
  formControls[subitem.name] = new FormControl(defaultValue ?? (subitem.default !== undefined ? subitem.default : ''), {
174
179
  validators: subitem.validators || [],
175
180
  updateOn: 'change'
176
181
  });
182
+ formControls[subitem.name].updateValueAndValidity({ onlySelf: false, emitEvent: true });
177
183
  }
178
184
  });
179
185
  }
@@ -915,7 +921,7 @@ class OnshoreFormDropdownItemComponent {
915
921
  this.cdr.markForCheck();
916
922
  }
917
923
  ngOnInit() {
918
- if (this.ngControl.control?.value == '' && this.formTemplate.default != undefined && !this.multiple) {
924
+ if ((!this.ngControl.control?.value || this.ngControl.control?.value == '' || this.ngControl.control?.value == undefined) && !this.multiple) {
919
925
  this.ngControl.control?.setValue(this.formTemplate.default);
920
926
  this.cdr.markForCheck();
921
927
  }
@@ -925,13 +931,10 @@ class OnshoreFormDropdownItemComponent {
925
931
  }
926
932
  ngOnChanges(changes) {
927
933
  const currentOptions = changes['options']?.currentValue ?? changes['formTemplate']?.currentValue?.options;
928
- const previousOptions = changes['options']?.previousValue ?? changes['formTemplate']?.previousValue?.options;
934
+ //const previousOptions = changes['options']?.previousValue ?? changes['formTemplate']?.previousValue?.options;
929
935
  if (!this.options && currentOptions) {
930
936
  this.options = currentOptions;
931
937
  }
932
- if (currentOptions?.length > 0 && currentOptions != previousOptions && !this.multiple) {
933
- this.ngControl.control?.setValue(this.options[0]?.value);
934
- }
935
938
  this.cdr.markForCheck();
936
939
  }
937
940
  }