Commit 894b358f authored by George Kalampokis's avatar George Kalampokis
Browse files

When deleting the first fieldset all the values from the second fieldset will...

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)
parent 69fde5f3
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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);
	}