diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java index 0bc911d14..254112460 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java @@ -219,8 +219,7 @@ public class DescriptionPersist { .must(() -> !this.isNull(item.getProperties())) .failOn(DescriptionPersist._properties).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionPersist._properties}, LocaleContextHolder.getLocale())), this.spec() - .iff(() -> item.getStatus() == DescriptionStatus.Finalized) - .must(() -> this.isDescriptionTemplateMultiplicityValid(finalDmpBlueprintEntity, item.getDmpId(), item.getDescriptionTemplateId())) + .must(() -> this.isDescriptionTemplateMaxMultiplicityValid(finalDmpBlueprintEntity, item.getDmpId(), item.getDmpDescriptionTemplateId(), this.isValidGuid(item.getId()))) .failOn(DescriptionPersist._descriptionTemplateId).failWith(messageSource.getMessage("Validation.InvalidDescriptionTemplateMultiplicity", new Object[]{DescriptionPersist._descriptionTemplateId}, LocaleContextHolder.getLocale())) // this.refSpec() // .iff(() -> !this.isNull(item.getProperties())) @@ -235,26 +234,28 @@ public class DescriptionPersist { ); } - private boolean isDescriptionTemplateMultiplicityValid(DmpBlueprintEntity dmpBlueprintEntity, UUID dmpId, UUID descriptionTemplateId){ + private boolean isDescriptionTemplateMaxMultiplicityValid(DmpBlueprintEntity dmpBlueprintEntity, UUID dmpId, UUID dmpDescriptionTemplateId, Boolean isUpdate){ eu.eudat.commons.types.dmpblueprint.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.dmpblueprint.DefinitionEntity.class, dmpBlueprintEntity.getDefinition()); if (definition == null || this.isListNullOrEmpty(definition.getSections())) return true; + DmpDescriptionTemplateEntity dmpDescriptionTemplateEntity = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(dmpDescriptionTemplateId).isActive(IsActive.Active).dmpIds(dmpId).first(); + if (dmpDescriptionTemplateEntity == null) return true; + + List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).dmpDescriptionTemplateIds(dmpDescriptionTemplateId).isActive(IsActive.Active).collect(); + for (SectionEntity section: definition.getSections()) { - if (section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ - int descriptionsCount = 0; + if (dmpDescriptionTemplateEntity.getSectionId().equals(section.getId()) && section.getHasTemplates() && !this.isListNullOrEmpty(section.getDescriptionTemplates())){ + int descriptionsCount; + if (isUpdate) descriptionsCount = -1; + else descriptionsCount = 0; for (eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity sectionDescriptionTemplate: section.getDescriptionTemplates()) { - if (sectionDescriptionTemplate.getMaxMultiplicity() == null && sectionDescriptionTemplate.getMinMultiplicity() == null ) continue; - - DmpDescriptionTemplateQuery dmpDescriptionTemplateQuery = this.queryFactory.query(DmpDescriptionTemplateQuery.class).isActive(IsActive.Active).dmpIds(dmpId).sectionIds(section.getId()); - List descriptionEntities = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).dmpIds(dmpId).dmpDescriptionTemplateSubQuery(dmpDescriptionTemplateQuery).isActive(IsActive.Active).collect(); - if (this.isListNullOrEmpty(descriptionEntities)) continue; - - for (DescriptionEntity description: descriptionEntities){ - if (description.getDescriptionTemplateId().equals(descriptionTemplateId)) descriptionsCount++; + if (sectionDescriptionTemplate.getDescriptionTemplateGroupId().equals(dmpDescriptionTemplateEntity.getDescriptionTemplateGroupId())){ + for (DescriptionEntity description: descriptionEntities){ + if (description.getDmpDescriptionTemplateId().equals(dmpDescriptionTemplateEntity.getId())) descriptionsCount++; + } + if (sectionDescriptionTemplate.getMaxMultiplicity() != null && sectionDescriptionTemplate.getMaxMultiplicity() <= descriptionsCount) return false; } - if (sectionDescriptionTemplate.getMinMultiplicity() != null && sectionDescriptionTemplate.getMinMultiplicity() >= descriptionsCount) return false; - if (sectionDescriptionTemplate.getMaxMultiplicity() != null && sectionDescriptionTemplate.getMaxMultiplicity() <= descriptionsCount) return false; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java index 0bb0ecf7d..6f4d03a33 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java @@ -54,6 +54,8 @@ public class DescriptionQuery extends QueryBase { private final UserScope userScope; private final AuthorizationService authService; private final QueryUtilsService queryUtilsService; + + private Collection dmpDescriptionTemplateIds; public DescriptionQuery(UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService) { this.userScope = userScope; this.authService = authService; @@ -110,7 +112,20 @@ public class DescriptionQuery extends QueryBase { return this; } + public DescriptionQuery dmpDescriptionTemplateIds(UUID value) { + this.dmpDescriptionTemplateIds = List.of(value); + return this; + } + public DescriptionQuery dmpDescriptionTemplateIds(UUID... value) { + this.dmpDescriptionTemplateIds = Arrays.asList(value); + return this; + } + + public DescriptionQuery dmpDescriptionTemplateIds(Collection values) { + this.dmpDescriptionTemplateIds = values; + return this; + } public DescriptionQuery finalizedAfter(Instant value) { this.finalizedAfter = value; @@ -287,6 +302,12 @@ public class DescriptionQuery extends QueryBase { QueryContext subQuery = this.applySubQuery(this.dmpQuery, queryContext, UUID.class, dmpEntityRoot -> dmpEntityRoot.get(DmpEntity._id)); predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)).value(subQuery.Query)); } + if (this.dmpDescriptionTemplateIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)); + for (UUID item : this.dmpDescriptionTemplateIds) + inClause.value(item); + predicates.add(inClause); + } if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); return queryContext.CriteriaBuilder.and(predicatesArray); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java index 8d2f9fcd4..2294ce10b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/prefillingsource/PrefillingSourceServiceImpl.java @@ -358,7 +358,9 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService { eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition()); Description description = new Description(); - description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, descriptionTemplateEntity)); + FieldSet descriptionTemplateFields = fieldSet.extractPrefixed(this.conventionService.asPrefix(Description._descriptionTemplate)); + + description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(descriptionTemplateFields, descriptionTemplateEntity)); return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO } diff --git a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts index 983535d49..0edb03b10 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp-blueprint.service.ts @@ -130,7 +130,8 @@ export class DmpBlueprintService { lookup.project = { fields: [ nameof(x => x.id), - nameof(x => x.label) + nameof(x => x.label), + nameof(x => x.version) ] }; lookup.order = { items: [nameof(x => x.label)] }; 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 b7bc41f0f..d89dd527f 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 @@ -550,6 +550,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor = []; - // DescriptionSectionFieldCategory = DescriptionSectionFieldCategory; - // DescriptionSystemFieldType = DescriptionSystemFieldType; - // public DescriptionSystemFieldTypeEnum = this.enumUtils.getEnumValues(DescriptionSystemFieldType); - // DescriptionExtraFieldDataType = DescriptionExtraFieldDataType; - // public DescriptionExtraFieldDataTypeEnum = this.enumUtils.getEnumValues(DescriptionExtraFieldDataType); - - // blueprintsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { - // filterFn: this.filterDescriptionTempaltes.bind(this), - // initialItems: (excludedItems: any[]) => this.filterDescriptionTempaltes('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), - // displayFn: (item: DatasetProfileModel) => item.label, - // titleFn: (item: DatasetProfileModel) => item.label, - // subtitleFn: (item: DatasetProfileModel) => item.description, - // popupItemActionIcon: 'visibility' - // }; - - // hasChanges = false; fieldsetIdWithFocus: string; viewOnly = false; @@ -211,10 +196,14 @@ export class DescriptionEditorComponent extends BaseEditor { + dialogRef.afterClosed().subscribe((result: Description) => { if (result) { result.dmp = this.item.dmp; result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate; + + const sectionId = this.item.dmpDescriptionTemplate.sectionId; + result.dmpDescriptionTemplate = this.item.dmp.dmpDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == result.descriptionTemplate.groupId); + this.prepareForm(result); // this.descriptionModel = this.descriptionModel.fromModel(result); // this.descriptionModel.dmp = data; @@ -551,6 +540,13 @@ export class DescriptionEditorComponent extends BaseEditor 0 && data.dmp?.descriptions?.length > 0){ + const section = data.dmp?.blueprint?.definition?.sections.find(x => x.id == data.dmpDescriptionTemplate?.sectionId); + if(section.hasTemplates) { + const notAvailableDescriptionTemplates = this.calculateMultiplicityRejectedDmpDescriptionTemplates(section, data.dmp.descriptions.filter(x => x.isActive == IsActive.Active)); + this.item.dmp.dmpDescriptionTemplates = data.dmp.dmpDescriptionTemplates.filter(x => !notAvailableDescriptionTemplates.map(y => y.id).includes(x.id) ) + } + } this.isDeleted = data ? data.isActive === IsActive.Inactive : false; this.buildForm(); } catch (error) { @@ -588,6 +584,26 @@ export class DescriptionEditorComponent extends BaseEditor 0){ + descriptions = descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === section.id) || []; + + let rejectedDmpDescriptionTemplates: DmpDescriptionTemplate[] = []; + section.descriptionTemplates.forEach(sectionDescriptionTemplate => { + if (sectionDescriptionTemplate.maxMultiplicity != null){ + const commonDescriptions = descriptions.filter(x => x.dmpDescriptionTemplate.descriptionTemplateGroupId == sectionDescriptionTemplate.descriptionTemplateGroupId); + + if (commonDescriptions && commonDescriptions.length >= sectionDescriptionTemplate.maxMultiplicity) { + rejectedDmpDescriptionTemplates = commonDescriptions.map(x => x.dmpDescriptionTemplate); + } + } + }) + return rejectedDmpDescriptionTemplates; + } else{ + return []; + } + } + refreshData(): void { this.getItem(this.editorModel.id, (data: Description) => this.prepareForm(data)); } 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 bc10ae268..64e8c0459 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 @@ -156,7 +156,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), // (prefix ? prefix + '.' : '') + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), // (prefix ? prefix + '.' : '') + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - // (prefix ? prefix + '.' : '') + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.sectionId)].join('.'), @@ -165,6 +165,13 @@ export class DescriptionEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.currentDescriptionTemplate), nameof(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.currentDescriptionTemplate), nameof(x => x.label)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.dmpDescriptionTemplates), nameof(x => x.currentDescriptionTemplate), nameof(x => x.version)].join('.'), + + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.id)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.isActive)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.descriptionTemplateGroupId)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.isActive)].join('.'), ] } diff --git a/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts index 73f4ce789..d3b0a1971 100644 --- a/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/prefill-description/prefill-description.component.ts @@ -17,6 +17,10 @@ import { TranslateService } from "@ngx-translate/core"; import { UUID } from "crypto"; import { Observable } from "rxjs"; import { map, takeUntil } from "rxjs/operators"; +import { DescriptionEditorResolver } from "../description-editor.resolver"; +import { nameof } from "ts-simple-nameof"; +import { Description } from "@app/core/model/description/description"; +import { IsActive } from "@app/core/common/enum/is-active.enum"; @Component({ selector: 'prefill-description-component', @@ -47,7 +51,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements this.dmp = data.dmp; this.dmpSectionId = data.dmpSectionId; - this.availableDescriptionTemplates = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId).map(x => x.currentDescriptionTemplate); + this.availableDescriptionTemplates = this.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.dmpSectionId && x.isActive == IsActive.Active).map(x => x.currentDescriptionTemplate); } ngOnInit() { @@ -212,7 +216,7 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements // } const formData = this.formService.getValue(this.prefillForm.value) as DescriptionProfilingRequest; - this.prefillingSourceService.generate(formData, DescriptionTemplateEditorResolver.lookupFields()) + this.prefillingSourceService.generate(formData, DescriptionEditorResolver.descriptionTemplateLookupFields(nameof(x => x.descriptionTemplate))) .pipe(takeUntil(this._destroyed)).subscribe(description => { if (description) { this.closeDialog(description); @@ -226,4 +230,4 @@ export class PrefillDescriptionDialogComponent extends BaseComponent implements closeDialog(result = null): void { this.dialogRef.close(result); } -} +} \ No newline at end of file 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 0df34205e..7e027be9b 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 @@ -96,11 +96,16 @@ 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 3278a61b6..3681cd3f1 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 @@ -18,7 +18,7 @@ import { IsActive } from '@app/core/common/enum/is-active.enum'; import { LockTargetType } from '@app/core/common/enum/lock-target-type'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { DescriptionSectionPermissionResolver } from '@app/core/model/description/description'; -import { DmpBlueprint } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DmpBlueprint, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp, DmpPersist } from '@app/core/model/dmp/dmp'; import { LanguageInfo } from '@app/core/model/language-info'; import { AuthService } from '@app/core/services/auth/auth.service'; @@ -88,6 +88,7 @@ export class DmpEditorComponent extends BaseEditor implemen filterFn: (searchQuery: string, data?: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(searchQuery, null, null, [DmpBlueprintStatus.Finalized])).pipe(map(x => x.items)), getSelectedItem: (selectedItem: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: DmpBlueprint) => item.label, + subtitleFn: (item: DmpBlueprint) => this.language.instant('DMP-EDITOR.FIELDS.DMP-BLUEPRINT-VERSION') + ' '+ item.version, titleFn: (item: DmpBlueprint) => item.label, valueAssign: (item: DmpBlueprint) => item.id, }; @@ -446,6 +447,32 @@ export class DmpEditorComponent extends BaseEditor implemen }); } + canAddDescription(section: DmpBlueprintDefinitionSection ): boolean{ + if(section.hasTemplates){ + if (section.descriptionTemplates?.length > 0){ + const descriptions = this.descriptionsInSection(section.id) + + let multiplicityValidResults :boolean[] = []; + section.descriptionTemplates.forEach(sectionDescriptionTemplate => { + if (sectionDescriptionTemplate.maxMultiplicity != null){ + const count = descriptions.filter(x => x.dmpDescriptionTemplate.descriptionTemplateGroupId == sectionDescriptionTemplate.descriptionTemplateGroupId).length || 0; + if (count >= sectionDescriptionTemplate.maxMultiplicity) multiplicityValidResults.push(false); + else multiplicityValidResults.push(true); + }else{ + multiplicityValidResults.push(true); + } + }) + + if(multiplicityValidResults.includes(true)) return true + else return false; + }else{ + return true; + } + }else{ + return false; + } + } + // // // Description Template 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 5bdfa8fbc..aa718bc02 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 @@ -61,6 +61,7 @@ export class DmpEditorResolver extends BaseEditorResolver { [nameof(x => x.descriptions), nameof(x => x.isActive)].join('.'), [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.id)].join('.'), [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.sectionId)].join('.'), + [nameof(x => x.descriptions), nameof(x => x.dmpDescriptionTemplate), nameof(x => x.descriptionTemplateGroupId)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), @@ -104,6 +105,8 @@ export class DmpEditorResolver extends BaseEditorResolver { (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateGroupId)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), + (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), (prefix ? prefix + '.' : '') + [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html index 42fa65450..0c5b91301 100644 --- a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.html @@ -34,7 +34,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts index a583898ec..2f7973b8d 100644 --- a/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts +++ b/dmp-frontend/src/app/ui/dmp/new-version-dialog/dmp-new-version-dialog.component.ts @@ -6,10 +6,13 @@ import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { BaseComponent } from '@common/base/base.component'; import { TranslateService } from '@ngx-translate/core'; -import { takeUntil } from 'rxjs/operators'; +import { map, takeUntil } from 'rxjs/operators'; import { DmpNewVersionDialogEditorModel } from './dmp-new-version-dialog.editor.model'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpEditorResolver } from '../dmp-editor-blueprint/dmp-editor.resolver'; +import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; +import { DmpBlueprint } from '@app/core/model/dmp-blueprint/dmp-blueprint'; +import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status'; @Component({ selector: 'app-dmp-new-version-dialog', @@ -22,6 +25,16 @@ export class NewVersionDmpDialogComponent extends BaseComponent { editorModel: DmpNewVersionDialogEditorModel; formGroup: UntypedFormGroup; + singleAutocompleteBlueprintConfiguration: SingleAutoCompleteConfiguration = { + initialItems: (data?: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(null, null, null, [DmpBlueprintStatus.Finalized])).pipe(map(x => x.items)), + filterFn: (searchQuery: string, data?: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(searchQuery, null, null, [DmpBlueprintStatus.Finalized])).pipe(map(x => x.items)), + getSelectedItem: (selectedItem: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), + displayFn: (item: DmpBlueprint) => item.label, + subtitleFn: (item: DmpBlueprint) => this.language.instant('DMP-EDITOR.FIELDS.DMP-BLUEPRINT-VERSION') + ' '+ item.version, + titleFn: (item: DmpBlueprint) => item.label, + valueAssign: (item: DmpBlueprint) => item.id, + }; + constructor( public dialogRef: MatDialogRef, private dmpService: DmpService, diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 428831044..52bfa0c04 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1304,7 +1304,8 @@ "EMAIL": "Email", "USER": "User", "USER-ROLE": "Role", - "SECTION": "Specific DMP Section" + "SECTION": "Specific DMP Section", + "DMP-BLUEPRINT-VERSION": "Version" }, "ACTIONS": { "DISCARD": "Discard",