onshore-forms 0.0.49 → 0.0.51
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.
- package/esm2020/lib/models/form.models.mjs +1 -1
- package/esm2020/lib/onshore-forms.service.mjs +10 -3
- package/fesm2015/onshore-forms.mjs +10 -2
- package/fesm2015/onshore-forms.mjs.map +1 -1
- package/fesm2020/onshore-forms.mjs +9 -2
- package/fesm2020/onshore-forms.mjs.map +1 -1
- package/lib/models/form.models.d.ts +4 -0
- package/lib/onshore-forms.service.d.ts +2 -2
- package/package.json +1 -1
|
@@ -156,23 +156,30 @@ class OnshoreFormsService {
|
|
|
156
156
|
formGroup(form, name) {
|
|
157
157
|
return form.get(name);
|
|
158
158
|
}
|
|
159
|
-
addFormArrayItem(formArray, item,
|
|
159
|
+
addFormArrayItem(formArray, item, defaultValues = null) {
|
|
160
160
|
let formControls = {};
|
|
161
161
|
if (item) {
|
|
162
162
|
item.subformArray?.forEach((subitem) => {
|
|
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
|
+
console.log("OSF - SET DEFAULT", defaultValue);
|
|
177
|
+
formControls[subitem.name] = new FormControl(defaultValue ?? (subitem.default !== undefined ? subitem.default : ''), {
|
|
173
178
|
validators: subitem.validators || [],
|
|
174
179
|
updateOn: 'change'
|
|
175
180
|
});
|
|
181
|
+
formControls[subitem.name].updateValueAndValidity({ onlySelf: false, emitEvent: true });
|
|
182
|
+
console.log("OSF - FORM CONTROL VAL", formControls[subitem.name], formControls[subitem.name].value);
|
|
176
183
|
}
|
|
177
184
|
});
|
|
178
185
|
}
|