issue fix on copy entity

This commit is contained in:
CITE\spapacharalampous 2024-08-28 10:47:43 +03:00
parent da77e5f144
commit ff0cb00d49
4 changed files with 29 additions and 5 deletions

View File

@ -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));
}

View File

@ -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({

View File

@ -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));
}

View File

@ -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 = {