From e5e1f238114527b0e5a1f4394ef560672cc1311a Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Wed, 24 Apr 2024 14:07:51 +0300 Subject: [PATCH] add Description template hasMultiplicity --- .../descriptiontemplate/FieldSetEntity.java | 10 ++++ .../importexport/FieldSetImportExport.java | 10 ++++ .../FieldSetCommonModelBuilder.java | 1 + .../FieldSetBuilder.java | 1 + .../FieldSet.java | 11 +++++ ...iptionFieldSetToDatasetFieldSetMapper.java | 2 +- .../PropertyDefinitionFieldSetPersist.java | 14 +++--- .../PropertyDefinitionPersist.java | 4 +- .../FieldSetPersist.java | 15 ++++++ .../DescriptionTemplateServiceImpl.java | 8 +++- ...ublicDatasetsDescriptionDocumentation.java | 1 + .../description-template-persist.ts | 2 +- .../description-template.ts | 2 +- ...late-editor-composite-field.component.html | 14 +++--- ...mplate-editor-composite-field.component.ts | 22 +++------ .../final-preview/final-preview.component.ts | 24 +++++----- .../description-template-editor.model.ts | 12 ++--- .../description-template-editor.resolver.ts | 2 +- .../editor/description-editor.resolver.ts | 1 + .../form-field-set.component.html | 6 +-- .../form-field-set.component.ts | 2 +- ...escriptionTemplateXmlMigrationService.java | 5 +- .../migration/MigrationController.java | 48 +++++++++---------- 23 files changed, 132 insertions(+), 85 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java index dc70c2a0a..c789bfbc9 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/FieldSetEntity.java @@ -27,6 +27,8 @@ public class FieldSetEntity { private String additionalInformation; @XmlElement(name="multiplicity") private MultiplicityEntity multiplicity; + @XmlAttribute(name="hasMultiplicity") + private boolean hasMultiplicity; @XmlAttribute(name="hasCommentField") private boolean hasCommentField; @@ -108,4 +110,12 @@ public class FieldSetEntity { public List getFieldById(String id) { return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); } + + public boolean getHasMultiplicity() { + return hasMultiplicity; + } + + public void setHasMultiplicity(boolean hasMultiplicity) { + this.hasMultiplicity = hasMultiplicity; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java index b0c0dad7b..e74c20465 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/descriptiontemplate/importexport/FieldSetImportExport.java @@ -27,6 +27,9 @@ public class FieldSetImportExport { private String additionalInformation; @XmlElement(name="multiplicity") private MultiplicityImportExport multiplicity; + + @XmlAttribute(name="hasMultiplicity") + private boolean hasMultiplicity; @XmlAttribute(name="hasCommentField") private Boolean hasCommentField; @@ -109,4 +112,11 @@ public class FieldSetImportExport { this.title = title; } + public boolean getHasMultiplicity() { + return hasMultiplicity; + } + + public void setHasMultiplicity(boolean hasMultiplicity) { + this.hasMultiplicity = hasMultiplicity; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/commonmodels/descriptiontemplate/FieldSetCommonModelBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/commonmodels/descriptiontemplate/FieldSetCommonModelBuilder.java index 89a025dff..72e1169ab 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/commonmodels/descriptiontemplate/FieldSetCommonModelBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/commonmodels/descriptiontemplate/FieldSetCommonModelBuilder.java @@ -56,6 +56,7 @@ public class FieldSetCommonModelBuilder extends BaseCommonModelBuilder(m, d)); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/FieldSetBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/FieldSetBuilder.java index 37da9ea27..5b9cf6cf2 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/FieldSetBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/FieldSetBuilder.java @@ -57,6 +57,7 @@ public class FieldSetBuilder extends BaseBuilder specifications(PropertyDefinitionFieldSetPersist item) { - Integer min = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : null; - Integer max = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : null; - if(min == 0 && max == 0) max = null; - Integer finalMax = max; + int min = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : 0; + int max = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : Integer.MAX_VALUE; return Arrays.asList( this.navSpec() @@ -60,13 +58,13 @@ public class PropertyDefinitionFieldSetPersist { .over(item.getItems()) .using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).setStatus(this.status)), this.spec() - .iff(() -> DescriptionStatus.Finalized.equals(this.status) && min != null) + .iff(() -> DescriptionStatus.Finalized.equals(this.status) && fieldSetEntity.getHasMultiplicity()) .must(() -> !this.isListNullOrEmpty(item.getItems()) && min <= item.getItems().size()) .failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LargerThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, min}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> DescriptionStatus.Finalized.equals(this.status) && finalMax != null) - .must(() -> !this.isListNullOrEmpty(item.getItems()) && finalMax >= item.getItems().size()) - .failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, finalMax}, LocaleContextHolder.getLocale())) + .iff(() -> DescriptionStatus.Finalized.equals(this.status) && fieldSetEntity.getHasMultiplicity()) + .must(() -> !this.isListNullOrEmpty(item.getItems()) && max >= item.getItems().size()) + .failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, max}, LocaleContextHolder.getLocale())) ); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptionproperties/PropertyDefinitionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptionproperties/PropertyDefinitionPersist.java index 0dc4fab0e..6ab00fbf0 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptionproperties/PropertyDefinitionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptionproperties/PropertyDefinitionPersist.java @@ -100,10 +100,10 @@ public class PropertyDefinitionPersist { if (definition == null || definition.getAllFieldSets() == null) return missingMultipleFieldSets; for (FieldSetEntity fieldSet: definition.getAllFieldSets()) { - boolean requiredAtLeastOneFieldSet = fieldSet.getMultiplicity() != null && fieldSet.getMultiplicity().getMin() > 0; + boolean requiredAtLeastOneFieldSet = fieldSet.getMultiplicity() != null && fieldSet.getHasMultiplicity() && fieldSet.getMultiplicity().getMin() > 0; if (requiredAtLeastOneFieldSet) { if (item == null || item.getFieldSets() == null) missingMultipleFieldSets.add(fieldSet); - if (item.getFieldSets() != null) { + if (item != null && item.getFieldSets() != null) { PropertyDefinitionFieldSetPersist fieldSetPersist = item.getFieldSets().getOrDefault(fieldSet.getId(), null); if (fieldSetPersist == null) missingMultipleFieldSets.add(fieldSet); } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java index e382e6dc1..72166f10e 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/FieldSetPersist.java @@ -45,6 +45,10 @@ public class FieldSetPersist { private MultiplicityPersist multiplicity = null; public static final String _multiplicity = "multiplicity"; + private Boolean hasMultiplicity; + public static final String _hasMultiplicity = "hasMultiplicity"; + + private Boolean hasCommentField = null; private List fields = null; @@ -131,6 +135,14 @@ public class FieldSetPersist { this.fields = fields; } + public Boolean getHasMultiplicity() { + return hasMultiplicity; + } + + public void setHasMultiplicity(Boolean hasMultiplicity) { + this.hasMultiplicity = hasMultiplicity; + } + @Component(FieldSetPersistValidator.ValidatorName) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public static class FieldSetPersistValidator extends BaseValidator { @@ -164,6 +176,9 @@ public class FieldSetPersist { this.spec() .must(() -> !this.isEmpty(item.getNumbering())) .failOn(FieldSetPersist._numbering).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._numbering}, LocaleContextHolder.getLocale())), + this.spec() + .must(() -> !this.isNull(item.getHasMultiplicity())) + .failOn(FieldSetPersist._hasMultiplicity).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._hasMultiplicity}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getTitle())) .failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())), diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 9f448b9e2..2ac518e86 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -349,14 +349,16 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic data.setDescription(persist.getDescription()); data.setOrdinal(persist.getOrdinal()); data.setTitle(persist.getTitle()); + data.setHasMultiplicity(persist.getHasMultiplicity()); data.setNumbering(persist.getNumbering()); data.setAdditionalInformation(persist.getAdditionalInformation()); data.setExtendedDescription(persist.getExtendedDescription()); - if (persist.getMultiplicity() != null && ( + if (persist.getMultiplicity() != null && persist.getHasMultiplicity() && ( (persist.getMultiplicity().getMin() != null && persist.getMultiplicity().getMin() != 0) || (persist.getMultiplicity().getMax() != null && persist.getMultiplicity().getMax() != 0) - )) + )) { data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity())); + } data.setHasCommentField(persist.getHasCommentField()); if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { @@ -833,6 +835,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic fieldSet1Entity.setOrdinal(importExport.getOrdinal()); fieldSet1Entity.setHasCommentField(importExport.getHasCommentField() != null ? importExport.getHasCommentField() : false); fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null); + fieldSet1Entity.setHasMultiplicity(importExport.getHasMultiplicity()); fieldSet1Entity.setTitle(importExport.getTitle()); fieldSet1Entity.setDescription(importExport.getDescription()); fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription()); @@ -970,6 +973,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic fieldSet1Entity.setId(entity.getId()); fieldSet1Entity.setOrdinal(entity.getOrdinal()); fieldSet1Entity.setHasCommentField(entity.getHasCommentField()); + fieldSet1Entity.setHasMultiplicity(entity.getHasMultiplicity()); fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null); fieldSet1Entity.setTitle(entity.getTitle()); fieldSet1Entity.setDescription(entity.getDescription()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java index d7df96fc9..bcb049a69 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java @@ -174,6 +174,7 @@ public class PublicDatasetsDescriptionDocumentation { String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._extendedDescription), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._ordinal), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._additionalInformation), + String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._hasMultiplicity), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._min), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._max), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._placeholder), diff --git a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts index cbe474847..1d4981076 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template-persist.ts @@ -49,7 +49,6 @@ export interface DescriptionTemplateSectionPersist { id: string; ordinal: number; defaultVisibility: boolean; - multiplicity: boolean; title: string; description: string; @@ -66,6 +65,7 @@ export interface DescriptionTemplateFieldSetPersist { extendedDescription: string; additionalInformation: string; multiplicity: DescriptionTemplateMultiplicityPersist; + hasMultiplicity: boolean; hasCommentField: boolean; fields: DescriptionTemplateFieldPersist[]; } diff --git a/dmp-frontend/src/app/core/model/description-template/description-template.ts b/dmp-frontend/src/app/core/model/description-template/description-template.ts index 09204149f..3ca14a895 100644 --- a/dmp-frontend/src/app/core/model/description-template/description-template.ts +++ b/dmp-frontend/src/app/core/model/description-template/description-template.ts @@ -47,7 +47,6 @@ export interface DescriptionTemplateSection { id?: string; ordinal?: number; defaultVisibility?: boolean; - multiplicity?: boolean; title?: string; description?: string; sections?: DescriptionTemplateSection[]; @@ -63,6 +62,7 @@ export interface DescriptionTemplateFieldSet { extendedDescription: string; additionalInformation: string; multiplicity: DescriptionTemplateMultiplicity + hasMultiplicity: boolean; hasCommentField: boolean; fields: DescriptionTemplateField[]; } diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html index 9e96f7b79..67fb2503c 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.html @@ -33,25 +33,25 @@
- + {{form.get('multiplicity').get('min').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{form.get('multiplicity').get('max').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}}
- + {{form.get('placeholder').get('multiplicity').getError('backendError').message}}
- + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}} {{form.get('multiplicity').get('tableView').getError('backendError').message}} @@ -110,7 +110,7 @@
- +
@@ -240,7 +240,7 @@ {{form.get('hasCommentField').getError('backendError').message}}
  • - + {{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}}
  • @@ -257,4 +257,4 @@
    - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts index 2dcd4b63e..426c4cf1e 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/composite-field/description-template-editor-composite-field.component.ts @@ -72,7 +72,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon private myCustomValidators: EditorCustomValidators = new EditorCustomValidators(); - isMultiplicityEnabled = false; constructor( private dialog: MatDialog, private language: TranslateService, @@ -89,16 +88,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon // this.showExtendedDescription = !!this.form.get('extendedDescription').value; // this.showAdditionalInfo = !!this.form.get('additionalInformation').value; // console.log(this.form.get('fields')['controls']) - if (changes['form']) { - - try { - const multiplicity = this.form.get('multiplicity').value; - this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max > 0; - } catch { - this.isMultiplicityEnabled = false; - } - } - } get firstField() { @@ -264,9 +253,11 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon description: formValue.description, extendedDescription: formValue.extendedDescription, additionalInformation: formValue.additionalInformation, + hasMultiplicity: formValue.hasMultiplicity, multiplicity: { - max: formValue.multiplicity.max, min: formValue.multiplicity.min, - placeholder: formValue.multiplicity.placeholder, tableView: formValue.multiplicity.tableView + max: formValue.multiplicity?.max, + min: formValue.multiplicity?.min, + placeholder: formValue.multiplicity?.placeholder, tableView: formValue.multiplicity?.tableView }, hasCommentField: formValue.hasCommentField, fields: fields @@ -342,13 +333,12 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon placeholder.setValue(''); tableView.setValue(false); } else { - minControl.setValue(0); - maxControl.setValue(0); + minControl.setValue(null); + maxControl.setValue(null); placeholder.setValue(null); tableView.setValue(null); } - this.isMultiplicityEnabled = isMultiplicityEnabled.checked; minControl.updateValueAndValidity(); maxControl.updateValueAndValidity(); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts index 0f2bd158b..bd4dc0616 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/final-preview/final-preview.component.ts @@ -20,7 +20,7 @@ export class FinalPreviewComponent implements OnInit { @Input() descriptionTemplatePersist: DescriptionTemplatePersist; descriptionTemplate: DescriptionTemplate; - + previewPropertiesFormGroup: UntypedFormGroup; constructor(public visibilityRulesService: VisibilityRulesService) { @@ -45,7 +45,7 @@ export class FinalPreviewComponent implements OnInit { } const descriptionEditorModel = new DescriptionEditorModel().fromModel(mockDescription, mockDescription.descriptionTemplate); this.previewPropertiesFormGroup = descriptionEditorModel.properties.buildForm() as UntypedFormGroup; - + this.visibilityRulesService.setContext(this.descriptionTemplate.definition, this.previewPropertiesFormGroup); } @@ -64,14 +64,14 @@ export class FinalPreviewComponent implements OnInit { status: persist.status, definition: this.buildDescriptionTemplateDefinition(persist.definition), users: persist.users - } + } } private buildDescriptionTemplateDefinition(persist: DescriptionTemplateDefinitionPersist) : DescriptionTemplateDefinition{ if (persist == null) return null; return { pages: persist.pages.map(x => this.buildDescriptionTemplatePage(x)) - } + } } private buildDescriptionTemplatePage(persist: DescriptionTemplatePagePersist) : DescriptionTemplatePage{ @@ -81,7 +81,7 @@ export class FinalPreviewComponent implements OnInit { ordinal: persist.ordinal, title: persist.title, sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)), - } + } } private buildDescriptionTemplateSection(persist: DescriptionTemplateSectionPersist) : DescriptionTemplateSection{ @@ -90,12 +90,11 @@ export class FinalPreviewComponent implements OnInit { id: persist.id, ordinal: persist.ordinal, defaultVisibility: persist.defaultVisibility, - multiplicity: persist.multiplicity, title: persist.title, description: persist.description, sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)), fieldSets: persist.fieldSets.map(x => this.buildDescriptionTemplateFieldSet(x)), - } + } } private buildDescriptionTemplateFieldSet(persist: DescriptionTemplateFieldSetPersist) : DescriptionTemplateFieldSet{ @@ -108,13 +107,16 @@ export class FinalPreviewComponent implements OnInit { description: persist.description, extendedDescription: persist.extendedDescription, additionalInformation: persist.additionalInformation, + hasMultiplicity: persist.hasMultiplicity, multiplicity: { - max: persist.multiplicity.max, min: persist.multiplicity.min, - placeholder: persist.multiplicity.placeholder, tableView: persist.multiplicity.tableView + max: persist.multiplicity?.max, + min: persist.multiplicity?.min, + placeholder: persist.multiplicity?.placeholder, + tableView: persist.multiplicity?.tableView }, hasCommentField: persist.hasCommentField, fields: persist.fields.map(x => this.buildDescriptionTemplateField(x)), - } + } } private buildDescriptionTemplateField (persist: DescriptionTemplateFieldPersist) : DescriptionTemplateField{ @@ -128,7 +130,7 @@ export class FinalPreviewComponent implements OnInit { validations: persist.validations, includeInExport: persist.includeInExport, data: persist.data, - } + } if (persist.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) { convertedField.data = persist.data; diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts index 9f31cdbc5..8333c8a02 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts @@ -361,7 +361,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat id: string; ordinal: number; defaultVisibility: boolean = false; // TODO: check if used and remove - multiplicity: boolean = false; title: string; description: string; sections: DescriptionTemplateSectionEditorModel[] = []; @@ -378,7 +377,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat this.id = item.id; this.ordinal = item.ordinal; this.defaultVisibility = item.defaultVisibility; - this.multiplicity = item.multiplicity; this.title = item.title; this.description = item.description; if (item.sections) { item.sections.map(x => this.sections.push(new DescriptionTemplateSectionEditorModel(this.validationErrorModel).fromModel(x))); } @@ -404,7 +402,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators], defaultVisibility: [{ value: this.defaultVisibility, disabled: disabled }, context.getValidation('defaultVisibility').validators], - multiplicity: [{ value: this.multiplicity, disabled: disabled }, context.getValidation('multiplicity').validators], title: [{ value: this.title, disabled: disabled }, context.getValidation('title').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], sections: this.formBuilder.array( @@ -439,7 +436,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); baseValidationArray.push({ key: 'defaultVisibility', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultVisibility`)] }); - baseValidationArray.push({ key: 'multiplicity', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}multiplicity`)] }); baseValidationArray.push({ key: 'title', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}title`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); baseValidationArray.push({ key: 'sections', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] }); @@ -461,7 +457,7 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat validationErrorModel }); - ['id', 'ordinal', 'defaultVisibility', 'multiplicity', 'page', 'title', 'description'].forEach(keyField => { + ['id', 'ordinal', 'defaultVisibility', 'page', 'title', 'description'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); @@ -495,6 +491,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla extendedDescription: string; additionalInformation: string; multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel); + hasMultiplicity: boolean = false; hasCommentField: boolean = false; fields: DescriptionTemplateFieldEditorModel[] = []; @@ -514,6 +511,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla this.extendedDescription = item.extendedDescription; this.additionalInformation = item.additionalInformation; this.hasCommentField = item.hasCommentField; + this.hasMultiplicity = item.hasMultiplicity; this.multiplicity = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel).fromModel(item.multiplicity); if (item.fields) { item.fields.map(x => this.fields.push(new DescriptionTemplateFieldEditorModel(this.validationErrorModel).fromModel(x))); } @@ -543,6 +541,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla extendedDescription: [{ value: this.extendedDescription, disabled: disabled }, context.getValidation('extendedDescription').validators], additionalInformation: [{ value: this.additionalInformation, disabled: disabled }, context.getValidation('additionalInformation').validators], hasCommentField: [{ value: this.hasCommentField, disabled: disabled }, context.getValidation('hasCommentField').validators], + hasMultiplicity: [{ value: this.hasMultiplicity, disabled: disabled }, context.getValidation('hasMultiplicity').validators], multiplicity: this.multiplicity.buildForm({ rootPath: `${rootPath}multiplicity.` }), @@ -572,6 +571,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla baseValidationArray.push({ key: 'extendedDescription', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extendedDescription`)] }); baseValidationArray.push({ key: 'additionalInformation', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}additionalInformation`)] }); baseValidationArray.push({ key: 'hasCommentField', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasCommentField`)] }); + baseValidationArray.push({ key: 'hasMultiplicity', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}hasMultiplicity`)] }); baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] }); baseContext.validation = baseValidationArray; @@ -590,7 +590,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla validationErrorModel }); - ['id', 'ordinal', 'numbering', 'title', 'description', 'extendedDescription', 'additionalInformation', 'hasCommentField'].forEach(keyField => { + ['id', 'ordinal', 'numbering', 'title', 'description', 'extendedDescription', 'additionalInformation', 'hasCommentField', 'hasMultiplicity'].forEach(keyField => { const control = formGroup?.get(keyField); control?.clearValidators(); control?.addValidators(context.getValidation(keyField).validators); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index 101aaefe8..1c7bb2c84 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -39,7 +39,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.id)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.defaultVisibility)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.multiplicity)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.title)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.description)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), @@ -53,6 +52,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.extendedDescription)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.additionalInformation)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasCommentField)].join('.'), + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasMultiplicity)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.min)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.max)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.placeholder)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index d7072f847..29bdf57fe 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -113,6 +113,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.extendedDescription)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.additionalInformation)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasCommentField)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.hasMultiplicity)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.min)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.max)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.multiplicity), nameof(x => x.placeholder)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html index 1837c2a4b..585c7f8b3 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field-set/form-field-set.component.html @@ -32,7 +32,7 @@ -
    +
    -
    +
    @@ -66,7 +66,7 @@ - +
    {{field.data?.label}}