From c9c0ea614b2752312e3810869eba9f269cca0d17 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Wed, 21 Feb 2024 17:52:50 +0200 Subject: [PATCH] reference types @ description editor --- .../fielddata/ReferenceTypeDataBuilder.java | 17 +++++++++++++++-- .../fielddata/ReferenceTypeData.java | 14 ++++++++------ .../description-template.ts | 3 ++- .../app/core/model/description/description.ts | 1 + .../editor/description-template-editor.model.ts | 2 +- .../description-template-editor.resolver.ts | 4 +++- .../editor/description-editor.model.ts | 5 +++-- .../editor/description-editor.resolver.ts | 6 ++++-- .../form-field/form-field.component.html | 8 ++++---- .../reference-field.component.html | 8 ++++++++ .../reference-field.component.ts | 8 +++++++- 11 files changed, 56 insertions(+), 20 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/ReferenceTypeDataBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/ReferenceTypeDataBuilder.java index b84a8826f..0eec04a00 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/ReferenceTypeDataBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/descriptiontemplatedefinition/fielddata/ReferenceTypeDataBuilder.java @@ -2,7 +2,13 @@ package eu.eudat.model.builder.descriptiontemplatedefinition.fielddata; import eu.eudat.commons.types.descriptiontemplate.fielddata.ReferenceTypeDataEntity; import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.ReferenceTypeBuilder; +import eu.eudat.model.builder.dmpblueprintdefinition.ReferenceFieldBuilder; import eu.eudat.model.descriptiontemplatedefinition.fielddata.ReferenceTypeData; +import eu.eudat.model.dmpblueprintdefinition.ReferenceTypeField; +import eu.eudat.query.ReferenceTypeQuery; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import org.slf4j.LoggerFactory; @@ -15,9 +21,14 @@ import org.springframework.stereotype.Component; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class ReferenceTypeDataBuilder extends BaseFieldDataBuilder { + private final QueryFactory queryFactory; + private final BuilderFactory builderFactory; + @Autowired - public ReferenceTypeDataBuilder(ConventionService conventionService) { + public ReferenceTypeDataBuilder(ConventionService conventionService, QueryFactory queryFactory, BuilderFactory builderFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceTypeDataBuilder.class))); + this.queryFactory = queryFactory; + this.builderFactory = builderFactory; } protected ReferenceTypeData getInstance() { @@ -26,6 +37,8 @@ public class ReferenceTypeDataBuilder extends BaseFieldDataBuilder(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.options), nameof(x => x.value)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.multipleSelect)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.type)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceTypeId)].join('.'), + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceType), nameof(x => x.id)].join('.'), + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceType), nameof(x => x.name)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.maxFileSizeInMB)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.label)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.value)].join('.'), diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts index 7b8fed036..c183330c7 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts @@ -225,6 +225,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp textListValue: undefined, dateValue: undefined, externalIdentifier: undefined, + references: undefined }); }) fieldSetValue.items = [{ @@ -429,8 +430,8 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist { this.textListValue = item.textListValue; this.dateValue = item.dateValue; //TODO: refactor reference type - //this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => x.reference); - //this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference; + // this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => x.reference); + // this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference; this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier); } return this; diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts index 889484c29..44cc72f24 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.resolver.ts @@ -1,9 +1,10 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; +import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption } from '@app/core/model/description-template/description-template'; import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionTag } from '@app/core/model/description/description'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpDescriptionTemplate } from '@app/core/model/dmp/dmp'; +import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { Reference } from '@app/core/model/reference/reference'; import { Tag } from '@app/core/model/tag/tag'; import { DescriptionService } from '@app/core/services/description/description.service'; @@ -101,7 +102,8 @@ export class DescriptionEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.type)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.maxFileSizeInMB)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.label)].join('.'), - (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.types), nameof(x => x.value)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceType), nameof(x => x.id)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.data), nameof(x => x.referenceType), nameof(x => x.name)].join('.'), ] } diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html index 9fe802bb2..a937c1542 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -16,12 +16,12 @@
- + +
diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html index b3a3c3328..f82199b98 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.html @@ -6,6 +6,14 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} {{hint}} + + {{label ?? referenceType?.name}} + + + {{form.getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{hint}} +
{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}} {{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}} diff --git a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts index 393c2dbc4..b8448ccc6 100644 --- a/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts +++ b/dmp-frontend/src/app/ui/reference/reference-field/reference-field.component.ts @@ -4,6 +4,7 @@ import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { BaseComponent } from '@common/base/base.component'; @Component({ @@ -22,6 +23,7 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { @Input() placeholder: string; multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration; + singleAutoCompleteSearchConfiguration: SingleAutoCompleteConfiguration; constructor( private referenceService: ReferenceService, @@ -29,7 +31,11 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { ) { super(); } ngOnInit() { - this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType.id); + if (this.multiple) { + this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType.id); + } else { + this.singleAutoCompleteSearchConfiguration = this.referenceService.getSingleAutocompleteSearchConfiguration(this.referenceType.id); + } } addReference() {