fix issue where adding multiple fields at the same time to an empty dropdown would only add the last field

This commit is contained in:
Art Lowel
2020-08-05 15:37:10 +02:00
parent c2fd019ebd
commit 8bfccaa624

View File

@@ -318,6 +318,12 @@ export class FormComponent implements OnDestroy, OnInit {
const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any; const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any;
if (model.type === DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN) { if (model.type === DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN) {
model.value = Object.values(value)[0]; model.value = Object.values(value)[0];
const ctrl = formArrayControl.controls[formArrayControl.length - 1];
const ctrlValue = ctrl.value;
const ctrlValueKey = Object.keys(ctrlValue)[0];
ctrl.setValue({
[ctrlValueKey]: model.value
});
} else if (this.formBuilderService.isQualdropGroup(model)) { } else if (this.formBuilderService.isQualdropGroup(model)) {
const ctrl = formArrayControl.controls[formArrayControl.length - 1]; const ctrl = formArrayControl.controls[formArrayControl.length - 1];
const ctrlKey = Object.keys(ctrl.value).find((key: string) => isNotEmpty(key.match(QUALDROP_GROUP_REGEX))); const ctrlKey = Object.keys(ctrl.value).find((key: string) => isNotEmpty(key.match(QUALDROP_GROUP_REGEX)));