add ui dmp remove template validation

This commit is contained in:
amentis 2024-04-19 12:29:21 +03:00
parent 0db2f12b1d
commit 8e9fee55aa
3 changed files with 24 additions and 1 deletions

View File

@ -299,7 +299,7 @@
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)">
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)" (optionRemoved)="onRemoveDescriptionTemplate($event, section.id)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>

View File

@ -562,6 +562,28 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> 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

View File

@ -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",