improvement on computing ordinal on mutliplicity fields
This commit is contained in:
parent
9cac208546
commit
faeb7e0d62
|
@ -74,8 +74,17 @@ export class FormSectionComponent implements OnInit, OnChanges {
|
||||||
addMultipleField(fieldsetIndex: number) {
|
addMultipleField(fieldsetIndex: number) {
|
||||||
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
|
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
|
||||||
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems')));
|
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 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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue