diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java index ebe690b8f..39ff17e50 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpReferenceQuery.java @@ -223,7 +223,7 @@ public class DmpReferenceQuery extends QueryBase { else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId; else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId; else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId; - else if (item.match(DmpReference._data)) return DmpReferenceEntity._data; + else if (item.prefix(DmpReference._data)) return DmpReferenceEntity._data; else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt; else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt; else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt; 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 b8a474150..f34e63bcc 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 @@ -604,6 +604,7 @@ public class DmpServiceImpl implements DmpService { dmpReferencePersist.setData(new DmpReferenceDataPersist()); dmpReferencePersist.getData().setBlueprintFieldId(fieldValuePersist.getFieldId()); dmpReferencePersist.setReference(referencePersist); + dmpReferencePersists.add(dmpReferencePersist); } } } @@ -668,6 +669,7 @@ public class DmpServiceImpl implements DmpService { if (!isUpdate) { data = new DmpReferenceEntity(); + data.setId(UUID.randomUUID()); data.setReferenceId(referenceEntity.getId()); data.setDmpId(dmpId); data.setCreatedAt(Instant.now()); diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 710d9ba08..5b3507a81 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -13,25 +13,25 @@ import { User } from "../user/user"; import { DmpReference } from './dmp-reference'; export interface Dmp extends BaseEntity { - label: string; - version: number; - status: DmpStatus; - versionStatus: DmpVersionStatus; - properties: DmpProperties; - groupId: String; - description: String; - finalizedAt: Date; - publishedAt: Date; - creator: User; - accessType: DmpAccessType; - blueprint: DmpBlueprint; - language: String; - publicAfter: Date; - dmpReferences: DmpReference[]; - dmpUsers: DmpUser[]; - descriptions: Description[]; - dmpDescriptionTemplates: DmpDescriptionTemplate[]; - entityDois: EntityDoi[]; + label?: string; + version?: number; + status?: DmpStatus; + versionStatus?: DmpVersionStatus; + properties?: DmpProperties; + groupId?: String; + description?: String; + finalizedAt?: Date; + publishedAt?: Date; + creator?: User; + accessType?: DmpAccessType; + blueprint?: DmpBlueprint; + language?: String; + publicAfter?: Date; + dmpReferences?: DmpReference[]; + dmpUsers?: DmpUser[]; + descriptions?: Description[]; + dmpDescriptionTemplates?: DmpDescriptionTemplate[]; + entityDois?: EntityDoi[]; } export interface DmpProperties { @@ -59,11 +59,11 @@ export interface DmpUser extends BaseEntity { } export interface DmpDescriptionTemplate extends BaseEntity { - dmp: Dmp; - currentDescriptionTemplate: DescriptionTemplate; //TODO: what is this? - descriptionTemplates: DescriptionTemplate[]; //TODO: why it is array? - descriptionTemplateGroupId: Guid; - sectionId: Guid; + dmp?: Dmp; + currentDescriptionTemplate?: DescriptionTemplate; //TODO: what is this? + descriptionTemplates?: DescriptionTemplate[]; //TODO: why it is array? + descriptionTemplateGroupId?: Guid; + sectionId?: Guid; } // @@ -107,7 +107,7 @@ export interface DmpReferenceDataPersist { blueprintFieldId: Guid; } -export interface DmpDescriptionTemplatePersist extends BaseEntityPersist { +export interface DmpDescriptionTemplatePersist { descriptionTemplateGroupId: Guid; sectionId: Guid; } diff --git a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts index cf8d41c8c..cf23e4648 100644 --- a/dmp-frontend/src/app/core/services/description-template/description-template.service.ts +++ b/dmp-frontend/src/app/core/services/description-template/description-template.service.ts @@ -163,7 +163,8 @@ export class DescriptionTemplateService { lookup.project = { fields: [ nameof(x => x.id), - nameof(x => x.label) + nameof(x => x.label), + nameof(x => x.groupId), ] }; lookup.order = { items: [nameof(x => x.label)] }; diff --git a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts index 6594a1e2e..44bf3feb4 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts @@ -219,6 +219,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor 0) { if (this.propertyCodes.includes(fieldCode)) { this.propertyCodes.splice(this.propertyCodes.indexOf(fieldCode), 1); diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html index 50e410696..347d0430a 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.html @@ -150,22 +150,22 @@
- +
- +
- +
- +
- +
- +
@@ -178,21 +178,21 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}}
- + --> +
@@ -240,18 +240,17 @@
- {{formGroup.get('descriptionTemplates').value | json}} + {{formGroup.get('descriptionTemplates').get(section.id).value | json}}
{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}
{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}} - + - {{formGroup.get('descriptionTemplates').get(section.id).get('descriptionTemplateGroupId').getError('backendError').message}} - {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts index f9417430e..5194df77f 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts @@ -38,7 +38,7 @@ import { LanguageInfo } from '@app/core/model/language-info'; import { LanguageInfoService } from '@app/core/services/culture/language-info-service'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { UntypedFormArray } from '@angular/forms'; +import { UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service'; @Component({ @@ -201,22 +201,33 @@ export class DmpEditorComponent extends BaseEditor implemen refreshOnNavigateToData(id?: Guid): void { this.formGroup.markAsPristine(); - let route = []; - if (id === null) { - route.push('../..'); - } else if (this.isNew) { + if (this.isNew) { + let route = []; route.push('../' + id); + this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route }); } else { - route.push('..'); + this.refreshData(); } - - this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route }); } persistEntity(onSuccess?: (response) => void): void { const formData = this.formService.getValue(this.formGroup.value) as DmpPersist; + //Transform to persist + //Transform descriptionTemplates + formData.descriptionTemplates = []; + for (const fieldId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) { + formData.descriptionTemplates.push(this.formGroup.get('descriptionTemplates').get(fieldId).value); + } + + //Transform properties + formData.properties.dmpBlueprintValues = []; + for (const fieldId in (this.formGroup.get('properties').get('dmpBlueprintValues') as UntypedFormGroup).controls) { + formData.properties.dmpBlueprintValues.push(this.formGroup.get('properties').get('dmpBlueprintValues').get(fieldId).value); + } + + this.dmpService.persist(formData) .pipe(takeUntil(this._destroyed)).subscribe( complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), @@ -293,6 +304,7 @@ export class DmpEditorComponent extends BaseEditor implemen selectBlueprint() { this.dmpBlueprintService.getSingle(this.formGroup.get('blueprint').value, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => { this.selectedBlueprint = data; + this.buildFormAfterBlueprintSelection(); this.nextStep(); }); } @@ -301,10 +313,20 @@ export class DmpEditorComponent extends BaseEditor implemen this.dmpBlueprintService.getSingle(this.configurationService.defaultBlueprintId, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => { this.selectedBlueprint = data; this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id); + this.buildFormAfterBlueprintSelection(); this.nextStep(); }); } + private buildFormAfterBlueprintSelection() { + const dmp: Dmp = { + label: this.formGroup.get('label').value, + description: this.formGroup.get('description').value, + blueprint: this.selectedBlueprint, + } + this.prepareForm(dmp); + } + // // @@ -312,7 +334,7 @@ export class DmpEditorComponent extends BaseEditor implemen // // public descriptionsInSection(sectionId: Guid) { - this.item.descriptions.filter(x => x.dmpDescriptionTemplate.sectionId === sectionId); + this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || []; } editDescription(id: string, isNew: boolean, showModal: boolean = false) { diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts index 925190814..7edbf9f8b 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.model.ts @@ -1,4 +1,4 @@ -import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; +import { FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; import { DmpAccessType } from "@app/core/common/enum/dmp-access-type"; import { DmpStatus } from "@app/core/common/enum/dmp-status"; import { DmpBlueprint } from "@app/core/model/dmp-blueprint/dmp-blueprint"; @@ -14,12 +14,11 @@ import { Guid } from "@common/types/guid"; export class DmpEditorModel extends BaseEditorModel implements DmpPersist { label: string; status: DmpStatus; - properties: DmpPropertiesEditorModel; + properties: DmpPropertiesEditorModel = new DmpPropertiesEditorModel(); description: String; language: String; blueprint: Guid; accessType: DmpAccessType; - // references: DmpReferenceEditorModel[] = []; descriptionTemplates: DmpDescriptionTemplateEditorModel[] = []; permissions: string[]; @@ -38,8 +37,36 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist { this.language = item.language; this.blueprint = item.blueprint?.id; this.accessType = item.accessType; - //if (item.dmpReferences) { item.dmpReferences.map(x => this.references.push(new DmpReferenceEditorModel().fromModel(x))); } - if (item.dmpDescriptionTemplates) { item.dmpDescriptionTemplates.map(x => this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel(x))); } + + item.blueprint.definition.sections.forEach(section => { + if (section.hasTemplates) { + const sectionTempaltesFromDmp = item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id) || []; + + if (sectionTempaltesFromDmp.length > 0) { + item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).forEach(dmpDescriptionTemplate => { + this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel( + { + sectionId: section.id, + descriptionTemplateGroupId: dmpDescriptionTemplate?.descriptionTemplateGroupId, + })); + }); + } else if (section.descriptionTemplates?.length > 0) { + section.descriptionTemplates.forEach(blueprintDefinedDescriptionTemplate => { + this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel( + { + sectionId: section.id, + descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateId, + })); + }); + } else { + this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel( + { + sectionId: section.id, + })); + } + } + + }); } return this; } @@ -58,32 +85,18 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist { language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators], blueprint: [{ value: this.blueprint, disabled: disabled }, context.getValidation('blueprint').validators], accessType: [{ value: this.accessType, disabled: disabled }, context.getValidation('accessType').validators], - // references: this.formBuilder.array( - // (this.references ?? []).map( - // (item, index) => new DmpReferenceEditorModel( - // this.validationErrorModel - // ).fromModel(item).buildForm({ - // rootPath: `references[${index}].` - // }), context.getValidation('references') - // ) - // ), hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators] }); - - // (this.references ?? []).filter(x => x?.data?.blueprintFieldId).map(x => x?.data?.blueprintFieldId).map( - // (item, index) => formGroup.addControl(item.data.blueprintFieldId.toString(), new DmpReferenceEditorModel( - // this.validationErrorModel - // ).fromModel(item).buildForm({ - // rootPath: `references[${index}].` - // })), context.getValidation('references') - // ) const descriptionTemplatesFormGroup = this.formBuilder.group({}); (this.descriptionTemplates ?? []).filter(x => x?.sectionId).map(x => x.sectionId).map( - (item, index) => descriptionTemplatesFormGroup.addControl(item.toString(), this.descriptionTemplates.find(x => x.sectionId === item).buildForm({ - rootPath: `descriptionTemplates[${index}].` - })), context.getValidation('descriptionTemplates') - ) + (item, index) => descriptionTemplatesFormGroup.addControl(item.toString(), + new FormControl(this.descriptionTemplates?.filter(x => x.sectionId === item)?.filter(x => x.descriptionTemplateGroupId).map(x => x.descriptionTemplateGroupId) || [], context.getValidation('descriptionTemplates').validators)) + ); + // // buildForm({ + // // rootPath: `descriptionTemplates[${index}].` + // })), //context.getValidation('descriptionTemplates') + // )) formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup); return formGroup; @@ -100,7 +113,6 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist { baseValidationArray.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] }); baseValidationArray.push({ key: 'blueprint', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprint')] }); baseValidationArray.push({ key: 'accessType', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'accessType')] }); - //baseValidationArray.push({ key: 'references', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'references')] }); baseValidationArray.push({ key: 'descriptionTemplates', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'descriptionTemplates')] }); baseValidationArray.push({ key: 'hash', validators: [] }); @@ -126,11 +138,10 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist { this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel( { fieldId: field.id, - fieldValue: item?.dmpBlueprintValues?.find(x => x.fieldId == field.id)?.fieldValue + fieldValue: item?.dmpBlueprintValues?.find(x => x.fieldId == field.id)?.fieldValue, }, dmpReferences)); }); }); - // if (item?.dmpBlueprintValues) { item.dmpBlueprintValues.map(x => this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel(x, dmpReferences))); } if (item?.contacts) { item.contacts.map(x => this.contacts.push(new DmpContactEditorModel().fromModel(x))); } return this; @@ -162,11 +173,14 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist { }); + + const dmpBlueprintValuesFormGroup = this.formBuilder.group({}); (this.dmpBlueprintValues ?? []).filter(x => x?.fieldId).map( - (item, index) => formGroup.addControl(item.fieldId.toString(), item.buildForm({ + (item, index) => dmpBlueprintValuesFormGroup.addControl(item.fieldId.toString(), item.buildForm({ rootPath: `dmpBlueprintValues[${index}].` })), context.getValidation('dmpBlueprintValues') ) + formGroup.addControl('dmpBlueprintValues', dmpBlueprintValuesFormGroup); return formGroup; } @@ -201,7 +215,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist { fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel { this.fieldId = item.fieldId; this.fieldValue = item.fieldValue; - this.references = dmpReferences.filter(x => x.data?.blueprintFieldId === this.fieldId); + this.references = dmpReferences?.filter(x => x.data?.blueprintFieldId === this.fieldId) || []; return this; } @@ -222,7 +236,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist { return this.formBuilder.group({ fieldId: [{ value: this.fieldId, disabled: disabled }, context.getValidation('fieldId').validators], fieldValue: [{ value: this.fieldValue, disabled: disabled }, context.getValidation('fieldValue').validators], - references: [{ value: this.references, disabled: disabled }, context.getValidation('references').validators], + references: [{ value: this.references?.map(x => x.reference), disabled: disabled }, context.getValidation('references').validators], }); } @@ -365,10 +379,8 @@ export class DmpReferenceEditorModel implements DmpReferencePersist { } export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplatePersist { - id: Guid; descriptionTemplateGroupId: Guid; sectionId: Guid; - hash: string; protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); @@ -377,10 +389,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate ) { } fromModel(item: DmpDescriptionTemplate): DmpDescriptionTemplateEditorModel { - this.id = item.id; this.descriptionTemplateGroupId = item.descriptionTemplateGroupId; this.sectionId = item.sectionId; - this.hash = item.hash; return this; } @@ -399,10 +409,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate } return this.formBuilder.group({ - id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators], descriptionTemplateGroupId: [{ value: this.descriptionTemplateGroupId, disabled: disabled }, context.getValidation('descriptionTemplateGroupId').validators], sectionId: [{ value: this.sectionId, disabled: disabled }, context.getValidation('sectionId').validators], - hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators] }); } @@ -414,10 +422,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate const baseContext: ValidationContext = new ValidationContext(); const baseValidationArray: Validation[] = new Array(); - baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] }); baseValidationArray.push({ key: 'descriptionTemplateGroupId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateGroupId`)] }); baseValidationArray.push({ key: 'sectionId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sectionId`)] }); - baseValidationArray.push({ key: 'hash', validators: [] }); baseContext.validation = baseValidationArray; return baseContext; diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts index 210fbe08d..dc0906c4b 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.resolver.ts @@ -3,7 +3,7 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Description } from '@app/core/model/description/description'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpBlueprintValue, DmpContact, DmpDescriptionTemplate, DmpProperties } from '@app/core/model/dmp/dmp'; -import { DmpReference } from '@app/core/model/dmp/dmp-reference'; +import { DmpReference, DmpReferenceData } from '@app/core/model/dmp/dmp-reference'; import { Reference } from '@app/core/model/reference/reference'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; @@ -26,12 +26,14 @@ export class DmpEditorResolver extends BaseEditorResolver { nameof(x => x.label), nameof(x => x.status), nameof(x => x.versionStatus), - nameof(x => x.accessType), - nameof(x => x.version), - nameof(x => x.isActive), nameof(x => x.groupId), + nameof(x => x.description), + nameof(x => x.language), + nameof(x => x.accessType), + nameof(x => x.isActive), nameof(x => x.version), nameof(x => x.updatedAt), + nameof(x => x.publicAfter), [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldId)].join('.'), [nameof(x => x.properties), nameof(x => x.dmpBlueprintValues), nameof(x => x.fieldValue)].join('.'), @@ -55,12 +57,13 @@ export class DmpEditorResolver extends BaseEditorResolver { // [nameof(x => x.dmpUsers), nameof(x => x.user.name)].join('.'), // [nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), - [nameof(x => x.dmpReferences), nameof(x => x.data)].join('.'), + [nameof(x => x.dmpReferences), nameof(x => x.data), nameof(x => x.blueprintFieldId)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.source)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.sourceType)].join('.'), [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.sectionId)].join('.'), 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 901107a2d..e7cfc285f 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 @@ -7,5 +7,5 @@
{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}} - {{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}} + {{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}
\ No newline at end of file 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 e1df7fc62..148f6c3d8 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 @@ -17,308 +17,28 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit { @Input() form: UntypedFormGroup = null; multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration; - // referenceTypeEnum = ReferenceType; - - // @Input() viewOnly = false; - // @Output() formChanged: EventEmitter = new EventEmitter(); - - // public filteringTagsAsync = false; - // public filteredTags: ExternalSourceItemModel[]; - - // readonly separatorKeysCodes: number[] = [ENTER, COMMA]; - - // externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - // filterFn: this.searchDatasetExternalDatasets.bind(this), - // initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), - // displayFn: (item) => item ? item.name : null, - // titleFn: (item) => item ? item.name : null, - // subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - // }; - - // registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - // filterFn: this.searchDatasetExternalRegistries.bind(this), - // initialItems: (type) => this.searchDatasetExternalRegistries('', type), - // displayFn: (item) => item ? item.name : null, - // titleFn: (item) => item ? item.name : null, - // subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - // }; - - // dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - // filterFn: this.searchDatasetExternalDataRepositories.bind(this), - // initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), - // displayFn: (item) => item ? item.name : null, - // titleFn: (item) => item ? item.name : null, - // subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - // }; - - // servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { - // filterFn: this.searchDatasetExternalServices.bind(this), - // initialItems: (type) => this.searchDatasetExternalServices('', type), - // displayFn: (item) => item ? item.label : null, - // titleFn: (item) => item ? item.label : null, - // subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') - // }; - - // tagsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - // filterFn: this.filterTags.bind(this), - // initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - // displayFn: (item) => this.showTag(item), - // titleFn: (item) => item['name'], - // valueAssign: (item) => this.addTag(item) - // }; - - // externalSourcesConfiguration: ExternalSourcesConfiguration; - - // // new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService), constructor( - // private dialog: MatDialog, - // private router: Router, - // private language: TranslateService, - // private externalSourcesService: ExternalSourcesService, - // private externalSourcesConfigurationService: ExternalSourcesConfigurationService, - // private externalDataRepositoryService: ExternalDataRepositoryService, - // private externalDatasetService: ExternalDatasetService, - // private externalRegistryService: ExternalRegistryService, private referenceService: ReferenceService, public enumUtils: EnumUtils, ) { super(); } ngOnInit() { this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType); - - - // this.externalSourcesConfigurationService.getExternalSourcesConfiguration() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // this.externalSourcesConfiguration = result; - // this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' }); - // this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' }); - // this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' }); - // this.externalSourcesConfiguration.services.push({ key: '', label: 'All' }); - // if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) { - // this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); - // } else { - // this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }]; - // } - // }); - - // this.formGroup.valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(val => { - // this.formChanged.emit(val); - // }); } - // public cancel(): void { - // this.router.navigate(['/datasets']); - // } - - // externalDatasetsOnItemChange(event) { - // const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source); - // (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - // } - - // registriesOnItemChange(event) { - // const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.pid ? event.pid : event.reference, event.uri, event.source); - // (this.formGroup.get('registries')).push(registryModel.buildForm()); - // } - - // servicesOnItemChange(event) { - // const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri); - // (this.formGroup.get('services')).push(serviceModel.buildForm()); - // } - - // tagsOnItemChange(event) { - // const tagModel = new ExternalTagEditorModel(event.id, event.name); - // (this.formGroup.get('tags')).push(tagModel.buildForm()); - // } - - - // dataRepositoriesOnItemChange(event) { - // const dataRepositoryModel = new ExternalDataRepositoryEditorModel(event.id, event.name, event.abbreviation, event.uri, event.pid, event.source); - // (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - // } - - // addDataRepository() { - // const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, { - // width: '500px', - // restoreFocus: false, - // data: {} - // }); - // dialogRef.afterClosed() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (!result) { return; } - // const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source); - // (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); - // }); - // } - - // addRegistry() { - // const dialogRef = this.dialog.open(DatasetExternalRegistryDialogEditorComponent, { - // width: '500px', - // restoreFocus: false, - // data: {} - // }); - // dialogRef.afterClosed() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (!result) { return; } - // const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - // (this.formGroup.get('registries')).push(registryModel.buildForm()); - // }); - // } - - // addExternalDataset() { - // const dialogRef = this.dialog.open(DatasetExternalDatasetDialogEditorComponent, { - // width: '500px', - // restoreFocus: false, - // data: {} - // }); - // dialogRef.afterClosed() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (!result) { return; } - // const externalDatasetModel = new ExternalDatasetEditorModel(result.id, result.abbreviation, result.name, result.reference, result.source); - // (this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm()); - // }); - // } - - // addService() { - // const dialogRef = this.dialog.open(DatasetExternalServiceDialogEditorComponent, { - // width: '500px', - // restoreFocus: false, - // data: {} - // }); - // dialogRef.afterClosed() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(result => { - // if (!result) { return; } - // const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source); - // (this.formGroup.get('services')).push(serviceModel.buildForm()); - // }); - // } - - // searchDatasetExternalDatasets(query: string, type: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new ExternalDatasetCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = type; - // return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); - // } - - // searchDatasetExternalDataRepositories(query: string, type: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new DataRepositoryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = type; - // return this.externalSourcesService.searchDatasetRepository(requestItem); - // } - - // searchDatasetExternalRegistries(query: string, type: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new RegistryCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = type; - // return this.externalSourcesService.searchDatasetRegistry(requestItem); - // } - - // searchDatasetExternalServices(query: string, type: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new ServiceCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = type; - // return this.externalSourcesService.searchDatasetService(requestItem); - // } - - // searchDatasetTags(query: string, type: string): Observable { - // const requestItem: RequestItem = new RequestItem(); - // requestItem.criteria = new TagCriteria(); - // requestItem.criteria.like = query; - // requestItem.criteria.type = type; - // return this.externalSourcesService.searchDatasetTags(requestItem); - // } - - // removeTag(tag: any) { - // (this.formGroup.get('tags')).removeAt(((this.formGroup.get('tags')).value as any[]).indexOf(tag)); - // } - - // addTag(ev: any) { - // let item: ExternalTagEditorModel; - // //this.filteredTags = this.formGroup.get('tags').value; - // if (typeof ev === 'string') { - // item = new ExternalTagEditorModel('', ev); - // } else { - // item = ev; - // } - // if (item.name !== '' ) { - // return item; - // } - // } - - // isInternal(element: any): boolean { - // if (element.get('source') == null) { - // // console.log(element); - // } - // return element.get('source').value === 'Internal'; - // } - - // updateDataRepository(dataRepository: UntypedFormGroup) { - // this.externalDataRepositoryService.create(dataRepository.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // (result) => { - // dataRepository.setValue(result); - // } - // ); - // } - - // updateExternalDataset(externalDataset: UntypedFormGroup) { - // this.externalDatasetService.create(externalDataset.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // (result) => { - // externalDataset.setValue(result); - // } - // ); - // } - - // updateRegistry(registry: UntypedFormGroup) { - // this.externalRegistryService.create(registry.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // (result) => { - // registry.setValue(result); - // } - // ); - // } - - // updateService(service: UntypedFormGroup) { - // this.externalServiceService.create(service.value) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // (result) => { - // service.setValue(result); - // } - // ); - // } - - // filterTags(value: string): Observable { - // this.filteringTagsAsync = true; - - // const requestItem: RequestItem = new RequestItem(); - // const criteria: TagCriteria = new TagCriteria(); - // criteria.like = value; - // requestItem.criteria = criteria; - // return this.externalSourcesService.searchDatasetTags(requestItem); - // } - - // showTag(ev: any) { - // if (typeof ev === 'string') { - // return ev; - // } else { - // return ev.name; - // } - // } + addReference() { + // const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, { + // width: '500px', + // restoreFocus: false, + // data: {} + // }); + // dialogRef.afterClosed() + // .pipe(takeUntil(this._destroyed)) + // .subscribe(result => { + // if (!result) { return; } + // const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source); + // (this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm()); + // }); + } }