add Description template hasMultiplicity

This commit is contained in:
Efstratios Giannopoulos 2024-04-24 14:07:51 +03:00
parent cd8545590e
commit e5e1f23811
23 changed files with 132 additions and 85 deletions

View File

@ -27,6 +27,8 @@ public class FieldSetEntity {
private String additionalInformation; private String additionalInformation;
@XmlElement(name="multiplicity") @XmlElement(name="multiplicity")
private MultiplicityEntity multiplicity; private MultiplicityEntity multiplicity;
@XmlAttribute(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField") @XmlAttribute(name="hasCommentField")
private boolean hasCommentField; private boolean hasCommentField;
@ -108,4 +110,12 @@ public class FieldSetEntity {
public List<FieldEntity> getFieldById(String id) { public List<FieldEntity> getFieldById(String id) {
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
} }
public boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
} }

View File

@ -27,6 +27,9 @@ public class FieldSetImportExport {
private String additionalInformation; private String additionalInformation;
@XmlElement(name="multiplicity") @XmlElement(name="multiplicity")
private MultiplicityImportExport multiplicity; private MultiplicityImportExport multiplicity;
@XmlAttribute(name="hasMultiplicity")
private boolean hasMultiplicity;
@XmlAttribute(name="hasCommentField") @XmlAttribute(name="hasCommentField")
private Boolean hasCommentField; private Boolean hasCommentField;
@ -109,4 +112,11 @@ public class FieldSetImportExport {
this.title = title; this.title = title;
} }
public boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
} }

View File

@ -56,6 +56,7 @@ public class FieldSetCommonModelBuilder extends BaseCommonModelBuilder<FieldSetM
m.setExtendedDescription(d.getExtendedDescription()); m.setExtendedDescription(d.getExtendedDescription());
m.setAdditionalInformation(d.getAdditionalInformation()); m.setAdditionalInformation(d.getAdditionalInformation());
if (d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity())); if (d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity()));
// if (d.getHasMultiplicity() != null) m.se(this.builderFactory.builder(MultiplicityCommonModelBuilder.class).authorize(this.authorize).build(d.getMultiplicity())); //TODO: HasMultiplicity
if (d.getFields() != null) m.setFields(this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).build(d.getFields())); if (d.getFields() != null) m.setFields(this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).build(d.getFields()));
models.add(new CommonModelBuilderItemResponse<>(m, d)); models.add(new CommonModelBuilderItemResponse<>(m, d));
} }

View File

@ -57,6 +57,7 @@ public class FieldSetBuilder extends BaseBuilder<eu.eudat.model.descriptiontempl
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._extendedDescription))) m.setExtendedDescription(d.getExtendedDescription()); if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._extendedDescription))) m.setExtendedDescription(d.getExtendedDescription());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._additionalInformation))) m.setAdditionalInformation(d.getAdditionalInformation()); if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._additionalInformation))) m.setAdditionalInformation(d.getAdditionalInformation());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasCommentField))) m.setHasCommentField(d.getHasCommentField()); if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasCommentField))) m.setHasCommentField(d.getHasCommentField());
if (fields.hasField(this.asIndexer(eu.eudat.model.descriptiontemplatedefinition.FieldSet._hasMultiplicity))) m.setHasMultiplicity(d.getHasMultiplicity());
if (!multiplicityFields.isEmpty() && d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityBuilder.class).authorize(this.authorize).build(multiplicityFields, d.getMultiplicity())); if (!multiplicityFields.isEmpty() && d.getMultiplicity() != null) m.setMultiplicity(this.builderFactory.builder(MultiplicityBuilder.class).authorize(this.authorize).build(multiplicityFields, d.getMultiplicity()));
if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields())); if (!fieldsFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(fieldsFields, d.getFields()));
models.add(m); models.add(m);

View File

@ -28,6 +28,9 @@ public class FieldSet {
public final static String _multiplicity = "multiplicity"; public final static String _multiplicity = "multiplicity";
private Multiplicity multiplicity; private Multiplicity multiplicity;
private Boolean hasMultiplicity;
public static final String _hasMultiplicity = "hasMultiplicity";
public final static String _hasCommentField = "hasCommentField"; public final static String _hasCommentField = "hasCommentField";
private Boolean hasCommentField; private Boolean hasCommentField;
@ -98,6 +101,14 @@ public class FieldSet {
this.multiplicity = multiplicity; this.multiplicity = multiplicity;
} }
public Boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(Boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
public Boolean getHasCommentField() { public Boolean getHasCommentField() {
return hasCommentField; return hasCommentField;
} }

View File

@ -22,7 +22,7 @@ public class DescriptionFieldSetToDatasetFieldSetMapper {
model.setTitle(fieldSet.getTitle()); model.setTitle(fieldSet.getTitle());
model.setAdditionalInformation(fieldSet.getAdditionalInformation()); model.setAdditionalInformation(fieldSet.getAdditionalInformation());
model.setExtendedDescription(fieldSet.getExtendedDescription()); model.setExtendedDescription(fieldSet.getExtendedDescription());
if (fieldSet.getMultiplicity() != null) { if (fieldSet.getMultiplicity() != null && fieldSet.getHasMultiplicity()) {
MultiplicityEntity multiplicityEntity = new MultiplicityEntity(); MultiplicityEntity multiplicityEntity = new MultiplicityEntity();
multiplicityEntity.setMin(fieldSet.getMultiplicity().getMin()); multiplicityEntity.setMin(fieldSet.getMultiplicity().getMin());
multiplicityEntity.setMax(fieldSet.getMultiplicity().getMax()); multiplicityEntity.setMax(fieldSet.getMultiplicity().getMax());

View File

@ -48,10 +48,8 @@ public class PropertyDefinitionFieldSetPersist {
@Override @Override
protected List<Specification> specifications(PropertyDefinitionFieldSetPersist item) { protected List<Specification> specifications(PropertyDefinitionFieldSetPersist item) {
Integer min = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : null; int min = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMin() : 0;
Integer max = fieldSetEntity != null && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : null; int max = fieldSetEntity != null && fieldSetEntity.getHasMultiplicity() && fieldSetEntity.getMultiplicity() != null ? fieldSetEntity.getMultiplicity().getMax() : Integer.MAX_VALUE;
if(min == 0 && max == 0) max = null;
Integer finalMax = max;
return Arrays.asList( return Arrays.asList(
this.navSpec() this.navSpec()
@ -60,13 +58,13 @@ public class PropertyDefinitionFieldSetPersist {
.over(item.getItems()) .over(item.getItems())
.using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).setStatus(this.status)), .using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).setStatus(this.status)),
this.spec() 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()) .must(() -> !this.isListNullOrEmpty(item.getItems()) && min <= item.getItems().size())
.failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LargerThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, min}, LocaleContextHolder.getLocale())), .failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LargerThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, min}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && finalMax != null) .iff(() -> DescriptionStatus.Finalized.equals(this.status) && fieldSetEntity.getHasMultiplicity())
.must(() -> !this.isListNullOrEmpty(item.getItems()) && finalMax >= item.getItems().size()) .must(() -> !this.isListNullOrEmpty(item.getItems()) && max >= item.getItems().size())
.failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, finalMax}, LocaleContextHolder.getLocale())) .failOn(PropertyDefinitionFieldSetPersist._items).failWith(messageSource.getMessage("Validation.LessThenEqual", new Object[]{PropertyDefinitionFieldSetPersist._items, max}, LocaleContextHolder.getLocale()))
); );
} }

View File

@ -100,10 +100,10 @@ public class PropertyDefinitionPersist {
if (definition == null || definition.getAllFieldSets() == null) return missingMultipleFieldSets; if (definition == null || definition.getAllFieldSets() == null) return missingMultipleFieldSets;
for (FieldSetEntity fieldSet: definition.getAllFieldSets()) { 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 (requiredAtLeastOneFieldSet) {
if (item == null || item.getFieldSets() == null) missingMultipleFieldSets.add(fieldSet); 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); PropertyDefinitionFieldSetPersist fieldSetPersist = item.getFieldSets().getOrDefault(fieldSet.getId(), null);
if (fieldSetPersist == null) missingMultipleFieldSets.add(fieldSet); if (fieldSetPersist == null) missingMultipleFieldSets.add(fieldSet);
} }

View File

@ -45,6 +45,10 @@ public class FieldSetPersist {
private MultiplicityPersist multiplicity = null; private MultiplicityPersist multiplicity = null;
public static final String _multiplicity = "multiplicity"; public static final String _multiplicity = "multiplicity";
private Boolean hasMultiplicity;
public static final String _hasMultiplicity = "hasMultiplicity";
private Boolean hasCommentField = null; private Boolean hasCommentField = null;
private List<FieldPersist> fields = null; private List<FieldPersist> fields = null;
@ -131,6 +135,14 @@ public class FieldSetPersist {
this.fields = fields; this.fields = fields;
} }
public Boolean getHasMultiplicity() {
return hasMultiplicity;
}
public void setHasMultiplicity(Boolean hasMultiplicity) {
this.hasMultiplicity = hasMultiplicity;
}
@Component(FieldSetPersistValidator.ValidatorName) @Component(FieldSetPersistValidator.ValidatorName)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static class FieldSetPersistValidator extends BaseValidator<FieldSetPersist> { public static class FieldSetPersistValidator extends BaseValidator<FieldSetPersist> {
@ -164,6 +176,9 @@ public class FieldSetPersist {
this.spec() this.spec()
.must(() -> !this.isEmpty(item.getNumbering())) .must(() -> !this.isEmpty(item.getNumbering()))
.failOn(FieldSetPersist._numbering).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._numbering}, LocaleContextHolder.getLocale())), .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() this.spec()
.must(() -> !this.isEmpty(item.getTitle())) .must(() -> !this.isEmpty(item.getTitle()))
.failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())), .failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())),

View File

@ -349,14 +349,16 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
data.setDescription(persist.getDescription()); data.setDescription(persist.getDescription());
data.setOrdinal(persist.getOrdinal()); data.setOrdinal(persist.getOrdinal());
data.setTitle(persist.getTitle()); data.setTitle(persist.getTitle());
data.setHasMultiplicity(persist.getHasMultiplicity());
data.setNumbering(persist.getNumbering()); data.setNumbering(persist.getNumbering());
data.setAdditionalInformation(persist.getAdditionalInformation()); data.setAdditionalInformation(persist.getAdditionalInformation());
data.setExtendedDescription(persist.getExtendedDescription()); data.setExtendedDescription(persist.getExtendedDescription());
if (persist.getMultiplicity() != null && ( if (persist.getMultiplicity() != null && persist.getHasMultiplicity() && (
(persist.getMultiplicity().getMin() != null && persist.getMultiplicity().getMin() != 0) (persist.getMultiplicity().getMin() != null && persist.getMultiplicity().getMin() != 0)
|| (persist.getMultiplicity().getMax() != null && persist.getMultiplicity().getMax() != 0) || (persist.getMultiplicity().getMax() != null && persist.getMultiplicity().getMax() != 0)
)) )) {
data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity())); data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
}
data.setHasCommentField(persist.getHasCommentField()); data.setHasCommentField(persist.getHasCommentField());
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
@ -833,6 +835,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
fieldSet1Entity.setOrdinal(importExport.getOrdinal()); fieldSet1Entity.setOrdinal(importExport.getOrdinal());
fieldSet1Entity.setHasCommentField(importExport.getHasCommentField() != null ? importExport.getHasCommentField() : false); fieldSet1Entity.setHasCommentField(importExport.getHasCommentField() != null ? importExport.getHasCommentField() : false);
fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null); fieldSet1Entity.setMultiplicity(importExport.getMultiplicity() != null ? this.xmlMultiplicityToPersist(importExport.getMultiplicity()) : null);
fieldSet1Entity.setHasMultiplicity(importExport.getHasMultiplicity());
fieldSet1Entity.setTitle(importExport.getTitle()); fieldSet1Entity.setTitle(importExport.getTitle());
fieldSet1Entity.setDescription(importExport.getDescription()); fieldSet1Entity.setDescription(importExport.getDescription());
fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription()); fieldSet1Entity.setExtendedDescription(importExport.getExtendedDescription());
@ -970,6 +973,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
fieldSet1Entity.setId(entity.getId()); fieldSet1Entity.setId(entity.getId());
fieldSet1Entity.setOrdinal(entity.getOrdinal()); fieldSet1Entity.setOrdinal(entity.getOrdinal());
fieldSet1Entity.setHasCommentField(entity.getHasCommentField()); fieldSet1Entity.setHasCommentField(entity.getHasCommentField());
fieldSet1Entity.setHasMultiplicity(entity.getHasMultiplicity());
fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null); fieldSet1Entity.setMultiplicity(entity.getMultiplicity() != null ? this.multiplicityXmlToExport(entity.getMultiplicity()) : null);
fieldSet1Entity.setTitle(entity.getTitle()); fieldSet1Entity.setTitle(entity.getTitle());
fieldSet1Entity.setDescription(entity.getDescription()); fieldSet1Entity.setDescription(entity.getDescription());

View File

@ -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._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._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._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._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._max),
String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._placeholder), String.join(".", Description._descriptionTemplate, DescriptionTemplate._definition, Definition._pages, Page._sections, Section._fieldSets, FieldSet._multiplicity, Multiplicity._placeholder),

View File

@ -49,7 +49,6 @@ export interface DescriptionTemplateSectionPersist {
id: string; id: string;
ordinal: number; ordinal: number;
defaultVisibility: boolean; defaultVisibility: boolean;
multiplicity: boolean;
title: string; title: string;
description: string; description: string;
@ -66,6 +65,7 @@ export interface DescriptionTemplateFieldSetPersist {
extendedDescription: string; extendedDescription: string;
additionalInformation: string; additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicityPersist; multiplicity: DescriptionTemplateMultiplicityPersist;
hasMultiplicity: boolean;
hasCommentField: boolean; hasCommentField: boolean;
fields: DescriptionTemplateFieldPersist[]; fields: DescriptionTemplateFieldPersist[];
} }

View File

@ -47,7 +47,6 @@ export interface DescriptionTemplateSection {
id?: string; id?: string;
ordinal?: number; ordinal?: number;
defaultVisibility?: boolean; defaultVisibility?: boolean;
multiplicity?: boolean;
title?: string; title?: string;
description?: string; description?: string;
sections?: DescriptionTemplateSection[]; sections?: DescriptionTemplateSection[];
@ -63,6 +62,7 @@ export interface DescriptionTemplateFieldSet {
extendedDescription: string; extendedDescription: string;
additionalInformation: string; additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicity multiplicity: DescriptionTemplateMultiplicity
hasMultiplicity: boolean;
hasCommentField: boolean; hasCommentField: boolean;
fields: DescriptionTemplateField[]; fields: DescriptionTemplateField[];
} }

View File

@ -33,25 +33,25 @@
</div> </div>
<div class="row"> <div class="row">
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field"> <mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MIN' | translate}}" type="number" [formControl]="form.get('multiplicity').get('min')"> <input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MIN' | translate}}" type="number" [formControl]="form.get('multiplicity').get('min')">
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('backendError')">{{form.get('multiplicity').get('min').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('min').hasError('backendError')">{{form.get('multiplicity').get('min').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('min').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('min').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pr-0 underline-line-field"> <mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pr-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MAX' | translate}}" type="number" [formControl]="this.form.get('multiplicity').get('max')"> <input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-MAX' | translate}}" type="number" [formControl]="this.form.get('multiplicity').get('max')">
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('backendError')">{{form.get('multiplicity').get('max').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('max').hasError('backendError')">{{form.get('multiplicity').get('max').getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.get('multiplicity').get('max').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('max').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="row"> <div class="row">
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field"> <mat-form-field *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field">
<input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-PLACEHOLDER' | translate}}" type="text" [formControl]="form.get('multiplicity').get('placeholder')"> <input matInput placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-PLACEHOLDER' | translate}}" type="text" [formControl]="form.get('multiplicity').get('placeholder')">
<mat-error *ngIf="form.get('multiplicity').get('placeholder').hasError('backendError')">{{form.get('placeholder').get('multiplicity').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('placeholder').hasError('backendError')">{{form.get('placeholder').get('multiplicity').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="row"> <div class="row">
<mat-checkbox *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field fieldset-checkbox-action-description-template-editor" [formControl]="form.get('multiplicity').get('tableView')"> <mat-checkbox *ngIf="this.form.get('hasMultiplicity')?.value" class="col pl-0 underline-line-field fieldset-checkbox-action-description-template-editor" [formControl]="form.get('multiplicity').get('tableView')">
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-TABLEVIEW' | translate}}
<mat-error *ngIf="form.get('multiplicity').get('tableView').hasError('backendError')">{{form.get('multiplicity').get('tableView').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('multiplicity').get('tableView').hasError('backendError')">{{form.get('multiplicity').get('tableView').getError('backendError').message}}</mat-error>
</mat-checkbox> </mat-checkbox>
@ -240,7 +240,7 @@
<mat-error *ngIf="form.get('hasCommentField').hasError('backendError')">{{form.get('hasCommentField').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('hasCommentField').hasError('backendError')">{{form.get('hasCommentField').getError('backendError').message}}</mat-error>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<mat-checkbox class="fieldset-checkbox-action-description-template-editor" [(checked)]="isMultiplicityEnabled" (change)="onIsMultiplicityEnabledChange($event)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.ENABLE-MULTIPLICITY' | translate" [disabled]="viewOnly"> <mat-checkbox class="fieldset-checkbox-action-description-template-editor" [formControl]="this.form.get('hasMultiplicity')" (change)="onIsMultiplicityEnabledChange($event)" [matTooltip]="'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.ENABLE-MULTIPLICITY' | translate" [disabled]="viewOnly">
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}} {{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FIELDSET.MULTIPLICITY' | translate}}
</mat-checkbox> </mat-checkbox>
</li> </li>

View File

@ -72,7 +72,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
private myCustomValidators: EditorCustomValidators = new EditorCustomValidators(); private myCustomValidators: EditorCustomValidators = new EditorCustomValidators();
isMultiplicityEnabled = false;
constructor( constructor(
private dialog: MatDialog, private dialog: MatDialog,
private language: TranslateService, private language: TranslateService,
@ -89,16 +88,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
// this.showExtendedDescription = !!this.form.get('extendedDescription').value; // this.showExtendedDescription = !!this.form.get('extendedDescription').value;
// this.showAdditionalInfo = !!this.form.get('additionalInformation').value; // this.showAdditionalInfo = !!this.form.get('additionalInformation').value;
// console.log(this.form.get('fields')['controls']) // 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() { get firstField() {
@ -264,9 +253,11 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
description: formValue.description, description: formValue.description,
extendedDescription: formValue.extendedDescription, extendedDescription: formValue.extendedDescription,
additionalInformation: formValue.additionalInformation, additionalInformation: formValue.additionalInformation,
hasMultiplicity: formValue.hasMultiplicity,
multiplicity: { multiplicity: {
max: formValue.multiplicity.max, min: formValue.multiplicity.min, max: formValue.multiplicity?.max,
placeholder: formValue.multiplicity.placeholder, tableView: formValue.multiplicity.tableView min: formValue.multiplicity?.min,
placeholder: formValue.multiplicity?.placeholder, tableView: formValue.multiplicity?.tableView
}, },
hasCommentField: formValue.hasCommentField, hasCommentField: formValue.hasCommentField,
fields: fields fields: fields
@ -342,13 +333,12 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
placeholder.setValue(''); placeholder.setValue('');
tableView.setValue(false); tableView.setValue(false);
} else { } else {
minControl.setValue(0); minControl.setValue(null);
maxControl.setValue(0); maxControl.setValue(null);
placeholder.setValue(null); placeholder.setValue(null);
tableView.setValue(null); tableView.setValue(null);
} }
this.isMultiplicityEnabled = isMultiplicityEnabled.checked;
minControl.updateValueAndValidity(); minControl.updateValueAndValidity();
maxControl.updateValueAndValidity(); maxControl.updateValueAndValidity();

View File

@ -90,7 +90,6 @@ export class FinalPreviewComponent implements OnInit {
id: persist.id, id: persist.id,
ordinal: persist.ordinal, ordinal: persist.ordinal,
defaultVisibility: persist.defaultVisibility, defaultVisibility: persist.defaultVisibility,
multiplicity: persist.multiplicity,
title: persist.title, title: persist.title,
description: persist.description, description: persist.description,
sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)), sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)),
@ -108,9 +107,12 @@ export class FinalPreviewComponent implements OnInit {
description: persist.description, description: persist.description,
extendedDescription: persist.extendedDescription, extendedDescription: persist.extendedDescription,
additionalInformation: persist.additionalInformation, additionalInformation: persist.additionalInformation,
hasMultiplicity: persist.hasMultiplicity,
multiplicity: { multiplicity: {
max: persist.multiplicity.max, min: persist.multiplicity.min, max: persist.multiplicity?.max,
placeholder: persist.multiplicity.placeholder, tableView: persist.multiplicity.tableView min: persist.multiplicity?.min,
placeholder: persist.multiplicity?.placeholder,
tableView: persist.multiplicity?.tableView
}, },
hasCommentField: persist.hasCommentField, hasCommentField: persist.hasCommentField,
fields: persist.fields.map(x => this.buildDescriptionTemplateField(x)), fields: persist.fields.map(x => this.buildDescriptionTemplateField(x)),

View File

@ -361,7 +361,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
id: string; id: string;
ordinal: number; ordinal: number;
defaultVisibility: boolean = false; // TODO: check if used and remove defaultVisibility: boolean = false; // TODO: check if used and remove
multiplicity: boolean = false;
title: string; title: string;
description: string; description: string;
sections: DescriptionTemplateSectionEditorModel[] = []; sections: DescriptionTemplateSectionEditorModel[] = [];
@ -378,7 +377,6 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
this.id = item.id; this.id = item.id;
this.ordinal = item.ordinal; this.ordinal = item.ordinal;
this.defaultVisibility = item.defaultVisibility; this.defaultVisibility = item.defaultVisibility;
this.multiplicity = item.multiplicity;
this.title = item.title; this.title = item.title;
this.description = item.description; this.description = item.description;
if (item.sections) { item.sections.map(x => this.sections.push(new DescriptionTemplateSectionEditorModel(this.validationErrorModel).fromModel(x))); } 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], id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators], ordinal: [{ value: this.ordinal, disabled: disabled }, context.getValidation('ordinal').validators],
defaultVisibility: [{ value: this.defaultVisibility, disabled: disabled }, context.getValidation('defaultVisibility').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], title: [{ value: this.title, disabled: disabled }, context.getValidation('title').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators], description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
sections: this.formBuilder.array( 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: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] }); baseValidationArray.push({ key: 'ordinal', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
baseValidationArray.push({ key: 'defaultVisibility', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}defaultVisibility`)] }); 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: 'title', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}title`)] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] }); baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
baseValidationArray.push({ key: 'sections', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] }); baseValidationArray.push({ key: 'sections', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sections`)] });
@ -461,7 +457,7 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
validationErrorModel validationErrorModel
}); });
['id', 'ordinal', 'defaultVisibility', 'multiplicity', 'page', 'title', 'description'].forEach(keyField => { ['id', 'ordinal', 'defaultVisibility', 'page', 'title', 'description'].forEach(keyField => {
const control = formGroup?.get(keyField); const control = formGroup?.get(keyField);
control?.clearValidators(); control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators); control?.addValidators(context.getValidation(keyField).validators);
@ -495,6 +491,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
extendedDescription: string; extendedDescription: string;
additionalInformation: string; additionalInformation: string;
multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel); multiplicity: DescriptionTemplateMultiplicityEditorModel = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel);
hasMultiplicity: boolean = false;
hasCommentField: boolean = false; hasCommentField: boolean = false;
fields: DescriptionTemplateFieldEditorModel[] = []; fields: DescriptionTemplateFieldEditorModel[] = [];
@ -514,6 +511,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
this.extendedDescription = item.extendedDescription; this.extendedDescription = item.extendedDescription;
this.additionalInformation = item.additionalInformation; this.additionalInformation = item.additionalInformation;
this.hasCommentField = item.hasCommentField; this.hasCommentField = item.hasCommentField;
this.hasMultiplicity = item.hasMultiplicity;
this.multiplicity = new DescriptionTemplateMultiplicityEditorModel(this.validationErrorModel).fromModel(item.multiplicity); 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))); } 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], extendedDescription: [{ value: this.extendedDescription, disabled: disabled }, context.getValidation('extendedDescription').validators],
additionalInformation: [{ value: this.additionalInformation, disabled: disabled }, context.getValidation('additionalInformation').validators], additionalInformation: [{ value: this.additionalInformation, disabled: disabled }, context.getValidation('additionalInformation').validators],
hasCommentField: [{ value: this.hasCommentField, disabled: disabled }, context.getValidation('hasCommentField').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({ multiplicity: this.multiplicity.buildForm({
rootPath: `${rootPath}multiplicity.` rootPath: `${rootPath}multiplicity.`
}), }),
@ -572,6 +571,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
baseValidationArray.push({ key: 'extendedDescription', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extendedDescription`)] }); baseValidationArray.push({ key: 'extendedDescription', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extendedDescription`)] });
baseValidationArray.push({ key: 'additionalInformation', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}additionalInformation`)] }); baseValidationArray.push({ key: 'additionalInformation', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}additionalInformation`)] });
baseValidationArray.push({ key: 'hasCommentField', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}hasCommentField`)] }); 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`)] }); baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
baseContext.validation = baseValidationArray; baseContext.validation = baseValidationArray;
@ -590,7 +590,7 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
validationErrorModel 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); const control = formGroup?.get(keyField);
control?.clearValidators(); control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators); control?.addValidators(context.getValidation(keyField).validators);

View File

@ -39,7 +39,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.id)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.id)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.defaultVisibility)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.defaultVisibility)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.multiplicity)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.title)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.title)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.description)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.description)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'),
@ -53,6 +52,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasMultiplicity)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'), [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'),

View File

@ -113,6 +113,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.extendedDescription)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.additionalInformation)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasCommentField)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.hasMultiplicity)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.min)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.max)].join('.'),
(prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'), (prefix ? prefix + '.' : '') + [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.multiplicity), nameof<DescriptionTemplateMultiplicity>(x => x.placeholder)].join('.'),

View File

@ -32,7 +32,7 @@
</button> </button>
</div> </div>
</div> </div>
<div *ngIf="(fieldSet?.multiplicity?.max - 1) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton"> <div *ngIf="fieldSet.hasMultiplicity && (fieldSet?.multiplicity?.max - 1) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()"> <span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
<button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled"> <button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled">
<mat-icon>add_circle</mat-icon> <mat-icon>add_circle</mat-icon>
@ -42,7 +42,7 @@
</span> </span>
</div> </div>
</div> </div>
<div *ngIf="fieldSet?.multiplicity?.tableView" class="col-12"> <div *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.tableView" class="col-12">
<table class="table table-bordered" style="table-layout: fixed"> <table class="table table-bordered" style="table-layout: fixed">
<tr> <tr>
<th *ngFor="let field of fieldSet.fields; let i = index;" class="text-wrap">{{field.data?.label}}</th> <th *ngFor="let field of fieldSet.fields; let i = index;" class="text-wrap">{{field.data?.label}}</th>
@ -66,7 +66,7 @@
</tr> </tr>
</ng-container> </ng-container>
<tr *ngIf="(fieldSet.multiplicity.max - 1) > propertiesFormGroup?.get('items')?.controls.length"> <tr *ngIf="fieldSet.hasMultiplicity && (fieldSet.multiplicity.max - 1) > propertiesFormGroup?.get('items')?.controls.length">
<td [colSpan]="fieldSet.fields.length + 1" class="text-center"> <td [colSpan]="fieldSet.fields.length + 1" class="text-center">
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()"> <span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
<button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled"> <button mat-icon-button color="primary" [disabled]="propertiesFormGroup.disabled">

View File

@ -29,7 +29,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
@Input() descriptionId: Guid; @Input() descriptionId: Guid;
get isMultiplicityEnabled() { get isMultiplicityEnabled() {
return this.fieldSet.multiplicity != null && this.fieldSet.multiplicity.min != 0 && this.fieldSet.multiplicity.max != 0; return this.fieldSet.hasMultiplicity && this.fieldSet.multiplicity != null;
} }

View File

@ -14,6 +14,7 @@ import eu.eudat.data.ReferenceTypeEntity;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import eu.eudat.model.DescriptionTemplate; import eu.eudat.model.DescriptionTemplate;
import eu.eudat.query.DescriptionTemplateQuery; import eu.eudat.query.DescriptionTemplateQuery;
import eu.old.eudat.logic.services.helpers.HelpersService;
import eu.old.eudat.logic.utilities.builders.XmlBuilder; import eu.old.eudat.logic.utilities.builders.XmlBuilder;
import eu.old.eudat.models.data.components.commons.Multiplicity; import eu.old.eudat.models.data.components.commons.Multiplicity;
import eu.old.eudat.models.data.components.commons.Rule; import eu.old.eudat.models.data.components.commons.Rule;
@ -172,7 +173,9 @@ public class DescriptionTemplateXmlMigrationService {
data.setExtendedDescription(persist.getExtendedDescription()); data.setExtendedDescription(persist.getExtendedDescription());
data.setAdditionalInformation(persist.getAdditionalInformation()); data.setAdditionalInformation(persist.getAdditionalInformation());
data.setHasCommentField(persist.getHasCommentField()); data.setHasCommentField(persist.getHasCommentField());
if (persist.getMultiplicity() != null) data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity())); data.setHasMultiplicity(persist.getMultiplicity() != null && (persist.getMultiplicity().getMin() != 0 || persist.getMultiplicity().getMax() != 0));
if (persist.getMultiplicity() != null && data.getHasMultiplicity()) data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
if (!this.conventionService.isListNullOrEmpty(persist.getFields())) { if (!this.conventionService.isListNullOrEmpty(persist.getFields())) {
data.setFields(new ArrayList<>()); data.setFields(new ArrayList<>());

View File

@ -90,36 +90,36 @@ public class MigrationController {
@GetMapping("all") @GetMapping("all")
@Transactional @Transactional
public boolean migrateAll() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException { public boolean migrateAll() throws IOException, JAXBException, ParserConfigurationException, InstantiationException, IllegalAccessException, SAXException, NoSuchFieldException, InvalidApplicationException, TransformerException, URISyntaxException {
//Reference // //Reference
this.dataRepositoryMigrationService.migrate(); // this.dataRepositoryMigrationService.migrate();
this.externalDatasetMigrationService.migrate(); // this.externalDatasetMigrationService.migrate();
this.funderMigrationService.migrate(); // this.funderMigrationService.migrate();
this.grantMigrationService.migrate(); // this.grantMigrationService.migrate();
this.organizationMigrationService.migrate(); // this.organizationMigrationService.migrate();
this.projectMigrationService.migrate(); // this.projectMigrationService.migrate();
this.registryMigrationService.migrate(); // this.registryMigrationService.migrate();
this.researcherMigrationService.migrate(); // this.researcherMigrationService.migrate();
this.serviceMigrationService.migrate(); // this.serviceMigrationService.migrate();
//
//User // //User
this.userContactInfoMigrationService.migrate(); // this.userContactInfoMigrationService.migrate();
this.userMigrationService.migrate(); // this.userMigrationService.migrate();
//XML recreate
this.dmpBlueprintXmlMigrationService.migrate();
this.descriptionTemplateXmlMigrationService.migrate();
// //XML recreate
// this.dmpBlueprintXmlMigrationService.migrate();
// this.descriptionTemplateXmlMigrationService.migrate();
//
//Dmp //Dmp
this.dmpMigrationService.migrate(); this.dmpMigrationService.migrate();
this.dmpDatasetProfileMigrationService.migrate(); this.dmpDatasetProfileMigrationService.migrate();
this.dmpUserMigrationService.migrate(); this.dmpUserMigrationService.migrate();
//Description // //Description
this.datasetMigrationService.migrate(); // this.datasetMigrationService.migrate();
this.datasetReferenceMigrationService.migrateDatasetReferences(); // this.datasetReferenceMigrationService.migrateDatasetReferences();
this.tagMigrationService.migrate(); // this.tagMigrationService.migrate();
//
this.storageFileMigrationService.migrate(); // this.storageFileMigrationService.migrate();
//throw new RuntimeException(""); //throw new RuntimeException("");
return true; return true;