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 4eb502ac0..e382e6dc1 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 @@ -167,10 +167,6 @@ public class FieldSetPersist { this.spec() .must(() -> !this.isEmpty(item.getTitle())) .failOn(FieldSetPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._title}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isEmpty(item.getDescription())) - .failOn(FieldSetPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldSetPersist._description}, LocaleContextHolder.getLocale())), - this.refSpec() .iff(() -> !this.isNull(item.getMultiplicity())) .on(FieldSetPersist._multiplicity) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java index 077ebeb71..0fa58deb2 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/SectionPersist.java @@ -151,18 +151,11 @@ public class SectionPersist { this.spec() .must(() -> !this.isEmpty(item.getTitle())) .failOn(SectionPersist._title).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._title}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isEmpty(item.getDescription())) - .failOn(SectionPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._description}, LocaleContextHolder.getLocale())), - this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getSections())) .on(SectionPersist._sections) .over(item.getSections()) .using((itm) -> this.validatorFactory.validator(SectionPersistValidator.class)), - this.spec() - .must(() -> !this.isListNullOrEmpty(item.getFieldSets())) - .failOn(SectionPersist._fieldSets).failWith(messageSource.getMessage("Validation_Required", new Object[]{SectionPersist._fieldSets}, LocaleContextHolder.getLocale())), this.navSpec() .iff(() -> !this.isListNullOrEmpty(item.getFieldSets())) .on(SectionPersist._fieldSets) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java index ef46e2fb7..b09df07c5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/BaseFieldDataPersist.java @@ -87,9 +87,6 @@ public abstract class BaseFieldDataPersist { protected List getBaseSpecifications(T item) { List specifications = new ArrayList<>(); specifications.addAll(Arrays.asList( - this.spec() - .must(() -> !this.isEmpty(item.getLabel())) - .failOn(BaseFieldDataPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isNull(item.getFieldType())) .failOn(BaseFieldDataPersist._fieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._fieldType}, LocaleContextHolder.getLocale())) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java index 6bdde45b1..4bbf1edae 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/ExternalDatasetDataPersist.java @@ -60,11 +60,7 @@ public class ExternalDatasetDataPersist extends BaseFieldDataPersist { specifications.addAll(Arrays.asList( this.spec() .must(() -> !this.isNull(item.getMultipleSelect())) - .failOn(ExternalDatasetDataPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._multipleSelect}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getType())) - .failOn(ExternalDatasetDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._type}, LocaleContextHolder.getLocale())) - + .failOn(ExternalDatasetDataPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{ExternalDatasetDataPersist._multipleSelect}, LocaleContextHolder.getLocale())) )); return specifications; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java index c673bf73c..bdc79d9f8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/RadioBoxDataPersist.java @@ -55,11 +55,8 @@ public class RadioBoxDataPersist extends BaseFieldDataPersist { this.spec() .must(() -> !this.isNull(item.getFieldType())) .failOn(BaseFieldDataPersist._fieldType).failWith(messageSource.getMessage("Validation_Required", new Object[]{BaseFieldDataPersist._fieldType}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getOptions())) - .failOn(RadioBoxDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{RadioBoxDataPersist._options}, LocaleContextHolder.getLocale())), this.navSpec() - .iff(() -> !this.isNull(item.getOptions())) + .iff(() -> !this.isListNullOrEmpty(item.getOptions())) .on(RadioBoxDataPersist._options) .over(item.getOptions()) .using((itm) -> this.validatorFactory.validator(RadioBoxOptionPersist.RadioBoxOptionPersistValidator.class)) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/SelectDataPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/SelectDataPersist.java index 4564154af..04b29ae72 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/SelectDataPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/descriptiontemplatedefinition/fielddata/SelectDataPersist.java @@ -68,10 +68,10 @@ public class SelectDataPersist extends BaseFieldDataPersist { .failOn(SelectDataPersist._multipleSelect).failWith(messageSource.getMessage("Validation_Required", new Object[]{SelectDataPersist._multipleSelect}, LocaleContextHolder.getLocale())), this.spec() - .must(() -> !this.isNull(item.getOptions())) + .must(() -> !this.isListNullOrEmpty(item.getOptions())) .failOn(SelectDataPersist._options).failWith(messageSource.getMessage("Validation_Required", new Object[]{SelectDataPersist._options}, LocaleContextHolder.getLocale())), this.navSpec() - .iff(() -> !this.isNull(item.getOptions())) + .iff(() -> !this.isListNullOrEmpty(item.getOptions())) .on(SelectDataPersist._options) .over(item.getOptions()) .using((itm) -> this.validatorFactory.validator(OptionPersist.ComboBoxOptionPersistValidator.class)) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/DescriptionTemplatePersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/DescriptionTemplatePersist.java index 22b29bfee..3959a8750 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/DescriptionTemplatePersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/dmpblueprintdefinition/DescriptionTemplatePersist.java @@ -87,7 +87,19 @@ public class DescriptionTemplatePersist { return Arrays.asList( this.spec() .must(() -> this.isValidGuid(item.getDescriptionTemplateGroupId())) - .failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())) + .failOn(DescriptionTemplatePersist._descriptionTemplateGroupId).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._descriptionTemplateGroupId}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isNull(item.getMinMultiplicity())) + .must(() -> item.getMinMultiplicity() >= 0) + .failOn(DescriptionTemplatePersist._minMultiplicity).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DescriptionTemplatePersist._minMultiplicity}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isNull(item.getMaxMultiplicity())) + .must(() -> item.getMaxMultiplicity() > 0) + .failOn(DescriptionTemplatePersist._maxMultiplicity).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{DescriptionTemplatePersist._maxMultiplicity}, LocaleContextHolder.getLocale())), + this.spec() + .iff(() -> !this.isNull(item.getMaxMultiplicity())) + .must(() -> !this.isNull(item.getMinMultiplicity()) && (item.getMaxMultiplicity() >= item.getMinMultiplicity())) + .failOn(DescriptionTemplatePersist._maxMultiplicity).failWith(messageSource.getMessage("Validation.LowerThanMin", new Object[]{DescriptionTemplatePersist._minMultiplicity}, LocaleContextHolder.getLocale())) ); } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java index 76d0110dd..91bce6f5d 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/ReferenceQuery.java @@ -36,6 +36,7 @@ public class ReferenceQuery extends QueryBase { private Collection referenceTypes; private Collection references; + private Collection sources; private Collection excludedIds; @@ -111,6 +112,21 @@ public class ReferenceQuery extends QueryBase { return this; } + public ReferenceQuery sources(String value) { + this.sources = List.of(value); + return this; + } + + public ReferenceQuery sources(String... value) { + this.sources = Arrays.asList(value); + return this; + } + + public ReferenceQuery sources(Collection values) { + this.sources = values; + return this; + } + public ReferenceQuery excludedIds(Collection values) { this.excludedIds = values; return this; @@ -177,7 +193,7 @@ public class ReferenceQuery extends QueryBase { @Override protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery); + return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) ||this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery); } @Override @@ -219,6 +235,12 @@ public class ReferenceQuery extends QueryBase { inClause.value(item); predicates.add(inClause); } + if (this.sources != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._source)); + for (String item : this.sources) + inClause.value(item); + predicates.add(inClause); + } if (this.excludedIds != null) { CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)); for (UUID item : this.excludedIds) diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DmpBlueprintLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DmpBlueprintLookup.java index c51eb4a6f..0301f27a3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DmpBlueprintLookup.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DmpBlueprintLookup.java @@ -21,6 +21,8 @@ public class DmpBlueprintLookup extends Lookup { private List excludedIds; + private List groupIds; + public String getLike() { return like; } @@ -37,6 +39,14 @@ public class DmpBlueprintLookup extends Lookup { this.isActive = isActive; } + public List getStatuses() { + return statuses; + } + + public void setStatuses(List statuses) { + this.statuses = statuses; + } + public List getIds() { return ids; } @@ -49,25 +59,32 @@ public class DmpBlueprintLookup extends Lookup { return excludedIds; } - public void setExcludedIds(List excludeIds) { - this.excludedIds = excludeIds; + public void setExcludedIds(List excludedIds) { + this.excludedIds = excludedIds; } - public List getStatuses() { - return statuses; + public List getGroupIds() { + return groupIds; } - public void setStatuses(List statuses) { - this.statuses = statuses; + public void setGroupIds(List groupIds) { + this.groupIds = groupIds; } public DmpBlueprintQuery enrich(QueryFactory queryFactory) { DmpBlueprintQuery query = queryFactory.query(DmpBlueprintQuery.class); - if (this.like != null) query.like(this.like); - if (this.isActive != null) query.isActive(this.isActive); - if (this.statuses != null) query.statuses(this.statuses); - if (this.ids != null) query.ids(this.ids); - if (this.excludedIds != null) query.excludedIds(this.excludedIds); + if (this.like != null) + query.like(this.like); + if (this.isActive != null) + query.isActive(this.isActive); + if (this.statuses != null) + query.statuses(this.statuses); + if (this.ids != null) + query.ids(this.ids); + if (this.excludedIds != null) + query.excludedIds(this.excludedIds); + if (this.groupIds != null) + query.groupIds(this.groupIds); this.enrichCommon(query); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index f90ef3514..2d416db90 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -512,12 +512,13 @@ public class DescriptionServiceImpl implements DescriptionService { referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId()); if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale())); } else { - referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).references(referencePersist.getReference()).first(); + referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first(); if (referenceEntity == null){ referenceEntity = new ReferenceEntity(); referenceEntity.setId(UUID.randomUUID()); referenceEntity.setIsActive(IsActive.Active); referenceEntity.setCreatedAt(Instant.now()); + referenceEntity.setType(referencePersist.getType()); referenceEntity.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(referencePersist.getDefinition()))); referenceEntity.setUpdatedAt(Instant.now()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java index 2970813b7..37fd26d96 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java @@ -647,12 +647,13 @@ public class DmpServiceImpl implements DmpService { referenceEntity = this.entityManager.find(ReferenceEntity.class, referencePersist.getId()); if (referenceEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{referencePersist.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale())); } else { - referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).references(referencePersist.getReference()).first(); + referenceEntity = this.queryFactory.query(ReferenceQuery.class).sourceTypes(referencePersist.getSourceType()).sources(referencePersist.getSource()).isActive(IsActive.Active).references(referencePersist.getReference()).first(); if (referenceEntity == null){ referenceEntity = new ReferenceEntity(); referenceEntity.setId(UUID.randomUUID()); referenceEntity.setIsActive(IsActive.Active); referenceEntity.setCreatedAt(Instant.now()); + referenceEntity.setType(referencePersist.getType()); referenceEntity.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(referencePersist.getDefinition()))); referenceEntity.setUpdatedAt(Instant.now()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index a12ea362f..0ce353028 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -407,7 +407,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { DmpBlueprintEntity data = new DmpBlueprintEntity(); data.setId(UUID.randomUUID()); data.setLabel(model.getLabel()); - data.setStatus(model.getStatus()); + data.setStatus(DmpBlueprintStatus.Draft); data.setDefinition(this.xmlHandlingService.toXml(this.buildDefinitionEntity(model.getDefinition()))); data.setGroupId(oldDmpBlueprintEntity.getGroupId()); data.setVersion((short) (oldDmpBlueprintEntity.getVersion() + 1)); diff --git a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts index ff758e018..2fd5249f2 100644 --- a/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts +++ b/dmp-frontend/src/app/core/model/dmp-blueprint/dmp-blueprint.ts @@ -11,6 +11,7 @@ export interface DmpBlueprint extends BaseEntity { definition: DmpBlueprintDefinition; status: DmpBlueprintStatus; version: number; + groupId: Guid; } export interface DmpBlueprintDefinition { diff --git a/dmp-frontend/src/app/core/query/dmp-blueprint.lookup.ts b/dmp-frontend/src/app/core/query/dmp-blueprint.lookup.ts index 3c18352ae..d32697e59 100644 --- a/dmp-frontend/src/app/core/query/dmp-blueprint.lookup.ts +++ b/dmp-frontend/src/app/core/query/dmp-blueprint.lookup.ts @@ -9,6 +9,7 @@ export class DmpBlueprintLookup extends Lookup implements DmpBlueprintFilter { like: string; isActive: IsActive[]; statuses: DmpBlueprintStatus[]; + groupIds: Guid[]; constructor() { super(); diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html index 255585aef..0b64347ff 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor-radio-box-field.component.html @@ -1,15 +1,17 @@
-
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' +
{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-TITLE' | translate}}
warning_amber - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}} + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED'| translate}} + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED' | translate}} + {{form.get('data').get('options').getError('backendError').message}}
@@ -17,14 +19,16 @@
- {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}} - + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-LABEL' | translate}} + {{option.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} - {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}} - + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-RADIO-BOX-VALUE' | translate}} + {{option.get('value').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
- {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-SELECT' | translate}} + {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-MULTIPLE-WORDLIST' | translate}} {{form.get('data').get('multipleSelect').getError('backendError').message}} @@ -36,6 +36,8 @@
+ {{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.FORM.FIELD.ERROR-MESSAGES.FIELD-RADIO-AT-LEAST-ONE-REQUIRED' | translate}} + {{form.get('data').get('options').getError('backendError').message}}
diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html index 8e97fb165..dc1f89400 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/components/section-fieldset/description-template-editor-section-fieldset.component.html @@ -65,7 +65,7 @@ [hasFocus]="fieldset.get('id').value === selectedFieldSetId" [datasetProfileId]="datasetProfileId" [validationErrorModel]="validationErrorModel" - [rootPath]="rootPath"> + [rootPath]="rootPath + 'fieldSets[' + i + '].'"> diff --git a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts index 027bc2fd4..e6064e396 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts @@ -616,6 +616,10 @@ export class DescriptionTemplateEditorComponent extends BaseEditor { parentSectionRootPath = parentSectionRootPath + 'sections[' + index +'].' }); + + sectionsArray = parent.form.get('sections') as UntypedFormArray; + + //adding page parent MAYBE NOT NEEDED + try { + const maxOrdinal = sectionsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)); + section.ordinal = maxOrdinal + 1; + } catch { + section.ordinal = sectionsArray.length; + } + + //store rootPath for next levels/components + this.rootPath = 'definition.pages['+ pageIndex +'].'+ parentSectionRootPath; + + sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' })); + // (child.form.parent as FormArray).push(section.buildForm()); + } - - sectionsArray = parent.form.get('sections') as UntypedFormArray; - - //adding page parent MAYBE NOT NEEDED - try { - const maxOrdinal = sectionsArray.controls.map(control => control.get('ordinal').value).reduce((a, b) => Math.max(a, b)); - section.ordinal = maxOrdinal + 1; - } catch { - section.ordinal = sectionsArray.length; - } - - sectionsArray.push(section.buildForm({ rootPath: 'definition.pages['+ pageIndex +'].' + parentSectionRootPath + 'sections[' + sectionsArray.length + '].' })); - // (child.form.parent as FormArray).push(section.buildForm()); - } else { console.error('Section can only be child of a page or another section'); } @@ -687,8 +694,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor item.buildForm({ rootPath: `${rootPath}sources[${index}].` - }), context.getValidation('sources') - ))); + }) + ), context.getValidation('sources').validators + )); return formGroup; } @@ -1583,8 +1584,9 @@ export class DescriptionTemplateRadioBoxDataEditorModel extends DescriptionTempl this.validationErrorModel ).fromModel(item).buildForm({ rootPath: `${rootPath}options[${index}].` - }), context.getValidation('options') - ))); + }) + ), context.getValidation('options').validators + )); return formGroup; } @@ -1729,8 +1731,9 @@ export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplat this.validationErrorModel ).fromModel(item).buildForm({ rootPath: `${rootPath}options[${index}].` - }), context.getValidation('options') - ))); + }) + ), context.getValidation('options').validators + )); return formGroup; } diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts index 80b6d697a..227789766 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/dmp-blueprint.routing.ts @@ -14,6 +14,14 @@ const routes: Routes = [ component: DmpBlueprintListingComponent, canActivate: [AuthGuard] }, + { + path: 'versions/:groupid', + component: DmpBlueprintListingComponent, + canActivate: [AuthGuard], + data: { + mode: 'versions-listing' + } + }, { path: 'new', canActivate: [AuthGuard], @@ -45,7 +53,6 @@ const routes: Routes = [ }, action: 'clone' } - }, { path: 'new-version/:newversionid', @@ -64,7 +71,6 @@ const routes: Routes = [ }, action: 'new-version' } - }, { path: ':id', diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts index df08ac997..18de7bda0 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.ts @@ -84,7 +84,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor this.initModelFlags(d['action'])); + this.route.data.subscribe(d => { + this.initModelFlags(d['action']); + }); } private initModelFlags(action: string): void { @@ -171,9 +173,13 @@ export class DmpBlueprintEditorComponent extends BaseEditor blueprint.get('descriptionTemplateId').value === event.id); - // if (foundIndex !== -1) { - // descriptionTemplateFormArray.removeAt(foundIndex); - // DmpBlueprintEditorModel.reApplySectionValidators( - // { - // formGroup: this.formGroup, - // validationErrorModel: this.editorModel.validationErrorModel - // } - // ) - // this.formGroup.get('definition').get('sections').markAsDirty(); - // } - // } - - // onSelectDescritionTemplate(item, sectionIndex) { - // ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray) - // .push(this.editorModel.createChildDescriptionTemplate(item, sectionIndex, ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray).length)); - - // } - - // ngAfterViewInit() { - - - - // this.route.params - // .pipe(takeUntil(this._destroyed)) - // .subscribe((params: Params) => { - // this.dmpBlueprintId = params['id']; - // const cloneId = params['cloneid']; - - // if (this.dmpBlueprintId != null) { - // this.isNew = false; - // this.dmpBlueprintService.getSingleBlueprint(this.dmpBlueprintId).pipe(map(data => data as any)) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(data => { - // this.dmpBlueprintEditor = new DmpBlueprintEditor().fromModel(data); - // this.formGroup = this.dmpBlueprintEditor.buildForm(); - // this.buildSystemFields(); - // this.fillDescriptionTemplatesInMultAutocomplete(); - // if (this.dmpBlueprintEditor.status == DmpBlueprintStatus.Finalized) { - // this.formGroup.disable(); - // this.viewOnly = true - // } - // // this.breadCrumbs = observableOf([{ - // // parentComponentName: 'DmpBlueprintListingComponent', - // // label: this.language.instant('NAV-BAR.TEMPLATE'), - // // url: '/dmp-blueprints/' + this.dmpBlueprintId - // // }]); - // }); - // } else if (cloneId != null) { - // this.isClone = true; - // this.dmpBlueprintService.clone(cloneId).pipe(map(data => data as any), takeUntil(this._destroyed)) - // .subscribe( - // data => { - // this.dmpBlueprintEditor = new DmpBlueprintEditor().fromModel(data); - // this.dmpBlueprintEditor.id = null; - // this.dmpBlueprintEditor.status = DmpBlueprintStatus.Draft; - // this.formGroup = this.dmpBlueprintEditor.buildForm(); - // this.buildSystemFields(); - // this.fillDescriptionTemplatesInMultAutocomplete(); - // }, - // error => this.onCallbackError(error) - // ); - // } else { - // this.dmpBlueprintEditorModel = new DmpBlueprintEditorModel(); - // this.dmpBlueprintEditor = new DmpBlueprintEditor(); - // setTimeout(() => { - // // this.formGroup = this.dmpBlueprintModel.buildForm(); - // // this.addField(); - // this.dmpBlueprintEditor.status = DmpBlueprintStatus.Draft; - // this.formGroup = this.dmpBlueprintEditor.buildForm(); - // }); - // // this.breadCrumbs = observableOf([{ - // // parentComponentName: 'DmpBlueprintListingComponent', - // // label: this.language.instant('NAV-BAR.TEMPLATE'), - // // url: '/dmp-blueprints/' + this.dmpBlueprintId - // // }]); - // } - // }); - - // } - - // buildSystemFields() { - // const sections = this.sectionsArray().controls.length; - // for (let i = 0; i < sections; i++) { - // let systemFieldsInSection = new Array(); - // this.fieldsArray(i).controls.forEach((field) => { - // if ((field.get('category').value == FieldCategory.SYSTEM || field.get('category').value == DmpBlueprintSectionFieldCategory.SYSTEM)) { - // systemFieldsInSection.push(this.fieldList.find(f => f.type == field.get('type').value).type); - // } - // }) - // this.systemFieldListPerSection.push(systemFieldsInSection); - // } - // } - - // fillDescriptionTemplatesInMultAutocomplete() { - // const sections = this.sectionsArray().controls.length; - // for (let i = 0; i < sections; i++) { - // let descriptionTemplatesInSection = new Array(); - // this.descriptionTemplatesArray(i).controls.forEach((template) => { - // descriptionTemplatesInSection.push({ id: template.value.descriptionTemplateId, label: template.value.label, description: "" }); - // }) - // this.descriptionTemplatesPerSection.push(descriptionTemplatesInSection); - // } - // } - - // checkForProfiles(event, sectionIndex: number) { - // if (event.checked === false) { - // this.descriptionTemplatesPerSection[sectionIndex] = new Array(); - // this.descriptionTemplatesArray(sectionIndex).clear(); - // } - // } - - - - // sectionsArray(): UntypedFormArray { - // //return this.dmpBlueprintsFormGroup.get('sections') as FormArray; - // return this.formGroup.get('definition').get('sections') as UntypedFormArray; - // } - - - // fieldsArray(sectionIndex: number): UntypedFormArray { - // return this.sectionsArray().at(sectionIndex).get('fields') as UntypedFormArray; - // } - - - - // removeField(sectionIndex: number, fieldIndex: number): void { - // this.fieldsArray(sectionIndex).removeAt(fieldIndex); - // } - - // systemFieldsArray(sectionIndex: number): UntypedFormArray { - // return this.sectionsArray().at(sectionIndex).get('systemFields') as UntypedFormArray; - // } - - // initSystemField(systemField?: SystemFieldType): UntypedFormGroup { - // return this.fb.group({ - // id: this.fb.control(Guid.create().toString()), - // type: this.fb.control(systemField), - // label: this.fb.control(''), - // placeholder: this.fb.control(''), - // description: this.fb.control(''), - // required: this.fb.control(true), - // ordinal: this.fb.control('') - // }); - // } - - // addSystemField(sectionIndex: number, systemField?: SystemFieldType): void { - // this.addField(sectionIndex, FieldCategory.SYSTEM, systemField); - // } - - // transfromEnumToString(type: SystemFieldType): string { - // return this.fieldList.find(f => f.type == type).label; - // } - - // selectedFieldType(type: SystemFieldType, sectionIndex: number): void { - // let index = this.systemFieldListPerSection[sectionIndex].indexOf(type); - // if (index == -1) { - // this.systemFieldListPerSection[sectionIndex].push(type); - // this.addSystemField(sectionIndex, type); - // } - // else { - // this.systemFieldListPerSection[sectionIndex].splice(index, 1); - // this.removeSystemField(sectionIndex, type); - // } - // } - - - - // descriptionTemplatesArray(sectionIndex: number): UntypedFormArray { - // return this.sectionsArray().at(sectionIndex).get('descriptionTemplates') as UntypedFormArray; - // } - - // addDescriptionTemplate(descriptionTemplate, sectionIndex: number): void { - // this.descriptionTemplatesArray(sectionIndex).push(this.fb.group({ - // label: this.fb.control(descriptionTemplate.value) - // })); - // } - - // removeDescriptionTemplate(sectionIndex: number, templateIndex: number): void { - // this.descriptionTemplatesArray(sectionIndex).removeAt(templateIndex); - // } - - // extraFieldsArray(sectionIndex: number): UntypedFormArray { - // return this.sectionsArray().at(sectionIndex).get('extraFields') as UntypedFormArray; - // } - - - - - - - - // getExtraFieldTypes(): Number[] { - // let keys: string[] = Object.keys(ExtraFieldType); - // keys = keys.slice(0, keys.length / 2); - // const values: Number[] = keys.map(Number); - // return values; - // } - - // getExtraFieldTypeValue(extraFieldType: ExtraFieldType): string { - // switch (extraFieldType) { - // case ExtraFieldType.TEXT: return 'Text'; - // case ExtraFieldType.RICH_TEXT: return 'Rich Text'; - // case ExtraFieldType.DATE: return 'Date'; - // case ExtraFieldType.NUMBER: return 'Number'; - // } - // } - - - - // moveItemInFormArray(formArray: UntypedFormArray, fromIndex: number, toIndex: number): void { - // const dir = toIndex > fromIndex ? 1 : -1; - - // const item = formArray.at(fromIndex); - // for (let i = fromIndex; i * dir < toIndex * dir; i = i + dir) { - // const current = formArray.at(i + dir); - // formArray.setControl(i, current); - // } - // formArray.setControl(toIndex, item); - // } - - // // clearForm(): void{ - // // this.dmpBlueprintsFormGroup.reset(); - // // } - onPreviewDescriptionTemplate(event: DescriptionTemplate, sectionId: Guid) { @@ -749,15 +521,6 @@ export class DmpBlueprintEditorComponent extends BaseEditor section.fields.some(field => (field.category === DmpBlueprintSectionFieldCategory.SYSTEM || field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM) && field.systemFieldType === DmpBlueprintSystemFieldType.TEXT)); @@ -787,119 +550,10 @@ export class DmpBlueprintEditorComponent extends BaseEditor this.onCallbackSuccess(), - // error => this.onCallbackError(error) - // ); - // } - - // onCallbackSuccess(): void { - // this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - // this.router.navigate(['/dmp-blueprints']); - // } - - // onCallbackError(errorResponse: any) { - // this.setErrorModel(errorResponse.error); - // this.formService.validateAllFormFields(this.formGroup); - // } - - // public setErrorModel(validationErrorModel: ValidationErrorModel) { - // Object.keys(validationErrorModel).forEach(item => { - // (this.dmpBlueprintEditor.validationErrorModel)[item] = (validationErrorModel)[item]; - // }); - // } - public cancel(): void { this.router.navigate(['/dmp-blueprints']); } - // // addField() { - // // (this.formGroup.get('definition').get('fields')).push(new DmpBlueprintFieldEditorModel().buildForm()); - // // } - - // // removeField(index: number) { - // // (this.formGroup.get('definition').get('fields')).controls.splice(index, 1); - // // } - - // getDmpBlueprintFieldDataTypeValues(): Number[] { - // let keys: string[] = Object.keys(DmpBlueprintFieldDataType); - // keys = keys.slice(0, keys.length / 2); - // const values: Number[] = keys.map(Number); - // return values; - // } - - // getDmpBlueprintFieldDataTypeWithLanguage(fieldType: DmpBlueprintFieldDataType): string { - // let result = ''; - // this.language.get(this.enumUtils.toDmpBlueprintExtraFieldDataTypeString(fieldType)) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((value: string) => { - // result = value; - // }); - // return result; - // } - - // getDmpBlueprintFieldTypeValues(): Number[] { - // let keys: string[] = Object.keys(DmpBlueprintType); - // keys = keys.slice(0, keys.length / 2); - // const values: Number[] = keys.map(Number); - // return values; - // } - - // getDmpBlueprintFieldTypeWithLanguage(blueprintType: DmpBlueprintType): string { - // let result = ''; - // this.language.get(this.enumUtils.toDmpBlueprintTypeString(blueprintType)) - // .pipe(takeUntil(this._destroyed)) - // .subscribe((value: string) => { - // result = value; - // }); - // return result; - // } - - // delete() { - // this.dialog.open(ConfirmationDialogComponent, { - // data: { - // isDeleteConfirmation: true, - // confirmButton: this.language.instant('DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.CONFIRM-BUTTON'), - // cancelButton: this.language.instant("DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.CANCEL-BUTTON"), - // message: this.language.instant("DMP-BLUEPRINT-EDITOR.CONFIRM-DELETE-DIALOG.MESSAGE") - // } - // }) - // .afterClosed() - // .subscribe( - // confirmed => { - // if (confirmed) { - // if (this.formGroup.get('status').value == DmpBlueprintStatus.Draft) { - // // this.formGroup.get('status').setValue(DmpBlueprintStatus.Deleted); - // this.dmpBlueprintService.createBlueprint(this.formGroup.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // complete => this.onCallbackSuccess(), - // error => this.onCallbackError(error) - // ); - // } - // else { - // // this.dmpBlueprintService.delete(this.dmpBlueprintId) - // // .pipe(takeUntil(this._destroyed)) - // // .subscribe( - // // complete => this.onCallbackSuccess(), - // // error => { - // // if (error.error.statusCode == 674) { - // // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DMP-BLUEPRINT-DELETE'), SnackBarNotificationLevel.Error); - // // } else { - // // this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - // // } - // // } - // // ); - // } - // } - // } - // ) - - // } - finalize() { if (this.checkValidity()) { this.formGroup.get('status').setValue(DmpBlueprintStatus.Finalized); diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html index 2d687c529..a6b6ac261 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html @@ -23,7 +23,7 @@ - + @@ -90,16 +90,20 @@ more_horiz - - - - +