From 429d4a35eaf2eccda350dff631b0b87c74d6ef80 Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 26 Apr 2024 18:03:34 +0300 Subject: [PATCH] add sActive description tags filter and fix dmp clone --- .../java/org/opencdmp/model/persist/CloneDmpPersist.java | 5 +---- .../main/java/org/opencdmp/service/dmp/DmpServiceImpl.java | 5 +++++ .../app/ui/description/editor/description-editor.model.ts | 2 +- .../app/ui/description/editor/description-editor.resolver.ts | 1 + .../src/app/ui/tag/tags-field/tags-field.component.ts | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java b/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java index 5b65b942f..957485c6c 100644 --- a/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java +++ b/backend/core/src/main/java/org/opencdmp/model/persist/CloneDmpPersist.java @@ -94,10 +94,7 @@ public class CloneDmpPersist { .failOn(CloneDmpPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._label}, LocaleContextHolder.getLocale())), this.spec() .must(() -> !this.isEmpty(item.getDescription())) - .failOn(CloneDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._description}, LocaleContextHolder.getLocale())), - this.spec() - .must(() -> !this.isNull(item.getDescriptions())) - .failOn(CloneDmpPersist._descriptions).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._descriptions}, LocaleContextHolder.getLocale())) + .failOn(CloneDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._description}, LocaleContextHolder.getLocale())) ); } } diff --git a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java index cd8f818d0..413212986 100644 --- a/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/dmp/DmpServiceImpl.java @@ -580,6 +580,11 @@ public class DmpServiceImpl implements DmpService { this.annotationEntityTouchedIntegrationEventHandler.handleDmp(newDmp.getId()); DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).ids(newDmp.getId()).firstAs(fields); + if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){ + for (UUID description: model.getDescriptions()) { + descriptionService.clone(newDmp.getId(), description); + } + } return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity); } 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 698f3745f..9f60d43af 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 @@ -36,7 +36,7 @@ export class DescriptionEditorModel extends BaseEditorModel implements Descripti this.descriptionTemplateId = item.descriptionTemplate?.id; this.status = item.status ?? DescriptionStatus.Draft; this.description = item.description; - this.tags = item.descriptionTags?.map(x => x.tag?.label); + this.tags = item.descriptionTags?.filter(x => x.isActive === IsActive.Active).map(x => x.tag?.label); this.properties = new DescriptionPropertyDefinitionEditorModel(this.validationErrorModel).fromModel(item.properties, descriptionTemplate, item.descriptionReferences); } 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 f64fe419c..8b3c93762 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 @@ -75,6 +75,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver { [nameof(x => x.descriptionTags), nameof(x => x.id),].join('.'), [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionTags), nameof(x => x.tag), nameof(x => x.isActive)].join('.'), [nameof(x => x.descriptionReferences), nameof(x => x.data), nameof(x => x.fieldId)].join('.'), [nameof(x => x.descriptionReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), diff --git a/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.ts b/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.ts index 4a0eb444b..c9bf5bd8f 100644 --- a/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.ts +++ b/dmp-frontend/src/app/ui/tag/tags-field/tags-field.component.ts @@ -63,6 +63,7 @@ export class TagsComponent extends BaseComponent implements OnInit { if (index >= 0) { this.tags.splice(index, 1); + this.form.setValue(this.tags); } }