Dataset Editor (Researchers Page). Incrementing ordinals on multiplicity items.
This commit is contained in:
parent
52c26cd864
commit
ba865c9708
|
@ -61,6 +61,13 @@ export class FormCompositeFieldComponent {
|
|||
const parent = this.form.parent;
|
||||
const index = (parent as FormArray).controls.indexOf(this.form);
|
||||
(parent as FormArray).removeAt(index);
|
||||
(parent as FormArray).controls.forEach((control, i)=>{
|
||||
try{
|
||||
control.get('ordinal').setValue(i);
|
||||
}catch{
|
||||
throw 'Could not find ordinal';
|
||||
}
|
||||
});
|
||||
// (<FormArray>(this.form as AbstractControl)).removeAt(fildIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ export class FormSectionInnerComponent implements OnInit, OnChanges {
|
|||
|
||||
addMultipleField(fieldsetIndex: number) {
|
||||
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
|
||||
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned);
|
||||
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems')));
|
||||
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, multiplicityItemsArray.length);
|
||||
multiplicityItemsArray.push(compositeField.buildForm());
|
||||
}
|
||||
|
||||
deleteCompositeFieldFormGroup(compositeFildIndex: number) {
|
||||
|
@ -72,7 +73,15 @@ export class FormSectionInnerComponent implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) {
|
||||
(<FormArray>(this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(fildIndex);
|
||||
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems')))
|
||||
multiplicityItemsArray.removeAt(fildIndex);
|
||||
multiplicityItemsArray.controls.forEach((control, i)=>{
|
||||
try{
|
||||
control.get('ordinal').setValue(i);
|
||||
}catch{
|
||||
throw 'Could not find ordinal';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// isElementVisible(fieldSet: CompositeField): boolean {
|
||||
|
|
|
@ -70,8 +70,9 @@ export class FormSectionComponent implements OnInit, OnChanges {
|
|||
|
||||
addMultipleField(fieldsetIndex: number) {
|
||||
const compositeFieldToBeCloned = (this.form.get('compositeFields').get('' + fieldsetIndex) as FormGroup).getRawValue();
|
||||
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned);
|
||||
(<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
|
||||
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + fieldsetIndex).get('multiplicityItems')));;
|
||||
const compositeField: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel().cloneForMultiplicity(compositeFieldToBeCloned, multiplicityItemsArray.length);
|
||||
multiplicityItemsArray.push(compositeField.buildForm());
|
||||
}
|
||||
|
||||
deleteCompositeFieldFormGroup(compositeFildIndex: number) {
|
||||
|
@ -84,7 +85,15 @@ export class FormSectionComponent implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
deleteMultipeFieldFromCompositeFormGroup(compositeFildIndex: number, fildIndex: number) {
|
||||
(<FormArray>(this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems'))).removeAt(fildIndex);
|
||||
const multiplicityItemsArray = (<FormArray>(this.form.get('compositeFields').get('' + compositeFildIndex).get('multiplicityItems')));
|
||||
multiplicityItemsArray.removeAt(fildIndex);
|
||||
multiplicityItemsArray.controls.forEach((control, i)=>{
|
||||
try{
|
||||
control.get('ordinal').setValue(i);
|
||||
}catch{
|
||||
throw 'Could not find ordinal';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// isElementVisible(fieldSet: CompositeField): boolean {
|
||||
|
|
|
@ -194,13 +194,13 @@ export class DatasetDescriptionCompositeFieldEditorModel extends BaseFormModel {
|
|||
// return newItem;
|
||||
// }
|
||||
|
||||
cloneForMultiplicity(item: CompositeField): DatasetDescriptionCompositeFieldEditorModel {
|
||||
cloneForMultiplicity(item: CompositeField, ordinal: number): DatasetDescriptionCompositeFieldEditorModel {
|
||||
const newItem: DatasetDescriptionCompositeFieldEditorModel = new DatasetDescriptionCompositeFieldEditorModel();
|
||||
newItem.id = 'multiple_' + item.id + '_' + Guid.create();
|
||||
item.fields.forEach((field, index) => {
|
||||
newItem.fields.push(new DatasetDescriptionFieldEditorModel().cloneForMultiplicity(field, newItem.id));
|
||||
});
|
||||
newItem.ordinal = item.ordinal;
|
||||
newItem.ordinal = ordinal;
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue