When deleting the first fieldset all the values from the second fieldset will be moved to the first fieldset instead of just the first value (ref #156)

This commit is contained in:
George Kalampokis 2020-01-29 12:38:16 +02:00
parent 69fde5f353
commit 894b358f9a
1 changed files with 5 additions and 2 deletions

View File

@ -61,8 +61,11 @@ export class FormSectionComponent implements OnInit, OnChanges {
}
deleteCompositeFieldFormGroup(compositeFildIndex: number) {
const firstMultiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + 0).value;
this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + 0).patchValue(firstMultiplicityItem);
const numberOfItems = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').value.length;
for (let i = 0; i < numberOfItems; i++) {
const multiplicityItem = this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems').get('' + 0).get('fields').get('' + i).value;
this.form.get('compositeFields').get('' + compositeFildIndex).get('fields').get('' + i).patchValue(multiplicityItem);
}
(<FormArray>(this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(0);
}