Fixed issue with dynamic group component

This commit is contained in:
Giuseppe Digilio
2018-12-10 16:07:26 +01:00
parent 97973f32c8
commit 251d93c4b3
2 changed files with 6 additions and 2 deletions

View File

@@ -120,7 +120,7 @@ export class DsDynamicGroupComponent implements OnDestroy, OnInit {
|| this.selectedChipItem.item[model.name].value === PLACEHOLDER_PARENT_METADATA) || this.selectedChipItem.item[model.name].value === PLACEHOLDER_PARENT_METADATA)
? null ? null
: this.selectedChipItem.item[model.name]; : this.selectedChipItem.item[model.name];
model.valueUpdates.next(value); model.valueUpdates.next(this.formBuilderService.isInputModel(model) ? value.value : value);
}); });
}); });

View File

@@ -4,7 +4,7 @@ import { AbstractControl, FormGroup } from '@angular/forms';
import { import {
DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP, DYNAMIC_FORM_CONTROL_TYPE_CHECKBOX_GROUP,
DYNAMIC_FORM_CONTROL_TYPE_GROUP, DYNAMIC_FORM_CONTROL_TYPE_GROUP, DYNAMIC_FORM_CONTROL_TYPE_INPUT,
DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP, DYNAMIC_FORM_CONTROL_TYPE_RADIO_GROUP,
DynamicFormArrayModel, DynamicFormArrayModel,
DynamicFormControlModel, DynamicFormControlModel,
@@ -271,6 +271,10 @@ export class FormBuilderService extends DynamicFormService {
return model.type === DYNAMIC_FORM_CONTROL_TYPE_ARRAY; return model.type === DYNAMIC_FORM_CONTROL_TYPE_ARRAY;
} }
isInputModel(model: DynamicFormControlModel): boolean {
return model.type === DYNAMIC_FORM_CONTROL_TYPE_INPUT;
}
getFormControlById(id: string, formGroup: FormGroup, groupModel: DynamicFormControlModel[], index = 0): AbstractControl { getFormControlById(id: string, formGroup: FormGroup, groupModel: DynamicFormControlModel[], index = 0): AbstractControl {
const fieldModel = this.findById(id, groupModel, index); const fieldModel = this.findById(id, groupModel, index);
return isNotEmpty(fieldModel) ? formGroup.get(this.getPath(fieldModel)) : null; return isNotEmpty(fieldModel) ? formGroup.get(this.getPath(fieldModel)) : null;