From ff0cb00d4952b0b352767413061c6c54ba79bb54 Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Wed, 28 Aug 2024 10:47:43 +0300 Subject: [PATCH] issue fix on copy entity --- .../description-template-editor.resolver.ts | 16 ++++++++++++++-- .../editor/plan-blueprint-editor.component.ts | 1 - .../editor/plan-blueprint-editor.resolver.ts | 15 +++++++++++++-- .../description-editor-entity.resolver.ts | 2 ++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index e0e67d2b5..3fbb7967f 100644 --- a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { DescriptionTemplateType } from '@app/core/model/description-template-type/description-template-type'; import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefaultValue, DescriptionTemplateDefinition, DescriptionTemplateExternalDatasetData, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection, DescriptionTemplateSelectData, DescriptionTemplateSelectOption, DescriptionTemplateUploadData, DescriptionTemplateUploadOption, UserDescriptionTemplate } from '@app/core/model/description-template/description-template'; @@ -10,7 +11,7 @@ import { DescriptionTemplateService } from '@app/core/services/description-templ import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { Guid } from '@common/types/guid'; -import { takeUntil, tap } from 'rxjs/operators'; +import { map, takeUntil, tap } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @Injectable() @@ -114,7 +115,18 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { if (id != null) { return this.descriptionTemplateService.getSingle(Guid.parse(id), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); } else if (cloneid != null) { - return this.descriptionTemplateService.clone(Guid.parse(cloneid), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)), takeUntil(this._destroyed)); + return this.descriptionTemplateService.clone(Guid.parse(cloneid), fieldSets) + .pipe( + tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)), + takeUntil(this._destroyed), + map((descriptionTemplate: DescriptionTemplate) => { + descriptionTemplate.id = null; + descriptionTemplate.hash = null; + descriptionTemplate.code = null; + descriptionTemplate.isActive = IsActive.Active; + + return descriptionTemplate; + })); } else if (newversion != null) { return this.descriptionTemplateService.getSingle(Guid.parse(newversion), fieldSets).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(newversion, x.label)), takeUntil(this._destroyed)); } diff --git a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts index 788ef1038..5a38ad836 100644 --- a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts +++ b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts @@ -45,7 +45,6 @@ import { PlanBlueprintEditorModel, FieldInSectionEditorModel } from './plan-blue import { PlanBlueprintEditorResolver } from './plan-blueprint-editor.resolver'; import { PlanBlueprintEditorService } from './plan-blueprint-editor.service'; import { RouterUtilsService } from '@app/core/services/router/router-utils.service'; -import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source'; @Component({ diff --git a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.resolver.ts b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.resolver.ts index 196cd89e2..4d60281f5 100644 --- a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.resolver.ts +++ b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.resolver.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; import { DescriptionTemplatesInSection, PlanBlueprint, PlanBlueprintDefinition, PlanBlueprintDefinitionSection, ExtraFieldInSection, FieldInSection, ReferenceTypeFieldInSection, SystemFieldInSection } from '@app/core/model/plan-blueprint/plan-blueprint'; import { PrefillingSource } from '@app/core/model/prefilling-source/prefilling-source'; import { ReferenceType } from '@app/core/model/reference-type/reference-type'; @@ -7,7 +8,7 @@ import { PlanBlueprintService } from '@app/core/services/plan/plan-blueprint.ser import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; import { BaseEditorResolver } from '@common/base/base-editor.resolver'; import { Guid } from '@common/types/guid'; -import { takeUntil, tap } from 'rxjs/operators'; +import { map, takeUntil, tap } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @Injectable() @@ -72,7 +73,17 @@ export class PlanBlueprintEditorResolver extends BaseEditorResolver { if (id != null) { return this.planBlueprintService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed)); } else if (cloneid != null) { - return this.planBlueprintService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)), takeUntil(this._destroyed)); + return this.planBlueprintService.clone(Guid.parse(cloneid), fields) + .pipe( + tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)), + takeUntil(this._destroyed), + map((blueprint: PlanBlueprint) => { + blueprint.id = null; + blueprint.hash = null; + blueprint.code = null; + blueprint.isActive = IsActive.Active; + return blueprint; + })); } else if (newversion != null) { return this.planBlueprintService.getSingle(Guid.parse(newversion), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(newversion, x.label)), takeUntil(this._destroyed)); } diff --git a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts index b956f2668..3f245d48d 100644 --- a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts +++ b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { DescriptionStatusEnum } from '@app/core/common/enum/description-status'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionReferenceData, DescriptionTag } from '@app/core/model/description/description'; @@ -200,6 +201,7 @@ export class DescriptionEditorEntityResolver extends BaseEditorResolver { description.id = null; description.hash = null; + description.isActive = IsActive.Active; description.status = DescriptionStatusEnum.Draft; description.plan = plan; description.planDescriptionTemplate = {