Commit faeb7e0d authored by Kristian Ntavidi's avatar Kristian Ntavidi
Browse files

improvement on computing ordinal on mutliplicity fields

parent 9cac2085
......@@ -74,8 +74,17 @@ export class FormSectionComponent implements OnInit, OnChanges {
addMultipleField(fieldsetIndex: number) {
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems')));
const ordinal = multiplicityItemsArray.length? multiplicityItemsArray.controls.reduce((ordinal, currentControl)=>{
const currentOrdinal = currentControl.get('ordinal').value as number;
if(currentOrdinal>= ordinal){
return currentOrdinal +1;
}
return ordinal as number;
},0) : 0;
const idMappings = [] as {old: string, new: string}[];
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, multiplicityItemsArray.length,idMappings);
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, ordinal ,idMappings);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment