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 46a02708d..9637acdf4 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 @@ -299,7 +299,7 @@
{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}
{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}} - + {{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} 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 04e2885d2..2d09eb1af 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 @@ -562,6 +562,28 @@ export class DmpEditorComponent extends BaseEditor implemen }); } + onRemoveDescriptionTemplate(event, sectionId: Guid){ + let foundDescription = false; + const descriptionsInSection = this.descriptionsInSection(sectionId); + let descriptionTemplatesInSection = this.formGroup.get('descriptionTemplates').get(sectionId.toString()).value as Guid[]; + + if (descriptionsInSection && descriptionsInSection.length > 0){ + for (let index = 0; index < descriptionsInSection.length; index++) { + const description = descriptionsInSection[index]; + if(description.dmpDescriptionTemplate?.descriptionTemplateGroupId === event.groupId) { + foundDescription = true; + this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Error); + break; + } + } + + if(foundDescription) { + if (descriptionTemplatesInSection) this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue(descriptionTemplatesInSection); + else this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue([]); + } + } + } + // // // Misc diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 29346d880..7a928074c 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1396,6 +1396,7 @@ "DESCRIPTION": "Description", "NO-TEMPLATE-MESSAGE": "If you can't find a template or if you want to create a personalized template for your institution, research community or training needs, please contact us.", "DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY": "Description Templates has reached the maximun multiplicity", + "UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more Descriptions of this Plan use this template", "FIELDS": { "TITLE": "Title of Plan", "DESCRIPTION": "Description",