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 480826958..a65ff6ef6 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 @@ -104,8 +104,14 @@ 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 21bc35e57..1b00babfc 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 @@ -298,9 +298,11 @@ export class DmpEditorComponent extends BaseEditor implemen //Transform descriptionTemplates formData.descriptionTemplates = []; for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) { - formData.descriptionTemplates.push( - ...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } }) - ); + if (this.formGroup.get('descriptionTemplates').get(sectionId).value != undefined){ + formData.descriptionTemplates.push( + ...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } }) + ); + } } this.dmpService.persist(formData) @@ -572,7 +574,12 @@ export class DmpEditorComponent extends BaseEditor implemen }); } - canAddDescription(section: DmpBlueprintDefinitionSection): boolean { + hasDescriptionTemplates(section: DmpBlueprintDefinitionSection): boolean { + if (this.item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).length > 0) return true; + return false; + } + + hasValidMultiplicity(section: DmpBlueprintDefinitionSection): boolean { if (section.hasTemplates) { if (section.descriptionTemplates?.length > 0) { const descriptions = this.descriptionsInSection(section.id)