diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts index 507f6a053..698f3745f 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts @@ -190,7 +190,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp let result: Map = new Map(); definitionSection?.fieldSets?.forEach(definitionFieldSet => { - const fieldSetResult = this.calculateFieldSetProperties(definitionFieldSet, item, descriptionReferences); + const fieldSetResult = this.calculateFieldSetProperties(definitionFieldSet, 0, item, descriptionReferences); if (fieldSetResult != null) { result.set(definitionFieldSet.id, fieldSetResult); } @@ -208,7 +208,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp return result; } - public calculateFieldSetProperties(definitionFieldSet: DescriptionTemplateFieldSet, item: DescriptionPropertyDefinition, descriptionReferences: DescriptionReference[]): DescriptionPropertyDefinitionFieldSetEditorModel { + public calculateFieldSetProperties(definitionFieldSet: DescriptionTemplateFieldSet, ordinal: number, item: DescriptionPropertyDefinition, descriptionReferences: DescriptionReference[]): DescriptionPropertyDefinitionFieldSetEditorModel { if (definitionFieldSet == null) return null; // current saved values @@ -229,7 +229,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp }) fieldSetValue.items = [{ fields: fields, - ordinal: 0 + ordinal: ordinal } as DescriptionPropertyDefinitionFieldSetItem] } @@ -744,7 +744,7 @@ export class DescriptionFieldIndicator { break; case DescriptionTemplateFieldType.TAGS: this.type = "textListValue"; - break; + break; } } } diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts index 063435ee4..92de8eedf 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.ts @@ -14,6 +14,7 @@ import { Guid } from '@common/types/guid'; import { AnnotationDialogComponent } from '@app/ui/annotations/annotation-dialog-component/annotation-dialog.component'; import { AnnotationEntityType } from '@app/core/common/enum/annotation-entity-type'; import { DescriptionFormAnnotationService } from '../../description-form-annotation.service'; +import { DescriptionPropertyDefinitionFieldSet } from '@app/core/model/description/description'; @Component({ selector: 'app-description-form-field-set', @@ -88,17 +89,21 @@ export class DescriptionFormFieldSetComponent extends BaseComponent { if (formArray.disabled) { return; } - - const item: DescriptionPropertyDefinitionFieldSetEditorModel = new DescriptionPropertyDefinitionEditorModel(this.validationErrorModel).calculateFieldSetProperties(this.fieldSet, null, null); + const properties: DescriptionPropertyDefinitionFieldSet = this.propertiesFormGroup.value; + let ordinal = 0; + if (properties?.items && properties.items.map(x => x.ordinal).filter(val => !isNaN(val)).length > 0) { + ordinal = Math.max(...properties.items.map(x => x.ordinal).filter(val => !isNaN(val))) + 1; + } + const item: DescriptionPropertyDefinitionFieldSetEditorModel = new DescriptionPropertyDefinitionEditorModel(this.validationErrorModel).calculateFieldSetProperties(this.fieldSet, ordinal, null, null); formArray.push((item.buildForm({ rootPath: `properties.fieldSets[${this.fieldSet.id}].` }).get('items') as UntypedFormArray).at(0)); - + this.visibilityRulesService.reloadVisibility(); } deleteMultiplicityField(fieldSetIndex: number): void { const formArray = this.propertiesFormGroup.get('items') as UntypedFormArray; formArray.removeAt(fieldSetIndex); formArray.controls.forEach((fieldSet, index) => { - fieldSet.get('ordinal').setValue(index + 1); + fieldSet.get('ordinal').setValue(index); }); //Reapply validators @@ -110,6 +115,8 @@ export class DescriptionFormFieldSetComponent extends BaseComponent { } ); formArray.markAsDirty(); + this.visibilityRulesService.reloadVisibility(); + } editTableMultiplicityFieldInDialog(fieldSetIndex: number) { diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html index c9195dbf4..2df2cfbe0 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -127,8 +127,8 @@
- {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }} - {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }} + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.YES" | translate }} + {{ "TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.ACTIONS.NO" | translate }} {{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}