diff --git a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.html b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.html
index c65b55ca4..d4d7e966a 100644
--- a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.html
+++ b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.html
@@ -3,16 +3,6 @@
@@ -252,7 +242,7 @@
{{'PLAN-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATE' | translate}}
-
+
{{descriptionTemplate.get('descriptionTemplateGroupId').getError('backendError').message}}
{{'GENERAL.VALIDATION.REQUIRED' | translate}}
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 f5b4b4067..b7b5f8ca7 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
@@ -71,16 +71,8 @@ export class PlanBlueprintEditorComponent extends BaseEditor
(PlanBlueprintExtraFieldDataType);
public planBlueprintFieldCategoryEnum = this.enumUtils.getEnumValues(PlanBlueprintFieldCategory);
- descriptionTempalteGroupSingleAutocompleteConfiguration: SingleAutoCompleteConfiguration = {
- initialItems: (data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active], null, null, null, this.getUsedDescriptionTemplateGroupIds())).pipe(map(x => x.items)),
- filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active], searchQuery, null, null, this.getUsedDescriptionTemplateGroupIds() ? this.getUsedDescriptionTemplateGroupIds() : null)).pipe(map(x => x.items)),
- getSelectedItem: (selectedItem: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active, IsActive.Inactive], null, null, [selectedItem])).pipe(map(x => x.items[0])),
- displayFn: (item: DescriptionTemplate) => item.label,
- titleFn: (item: DescriptionTemplate) => item.label,
- subtitleFn: (item: DescriptionTemplate) => item.description,
- valueAssign: (item: DescriptionTemplate) => item.groupId,
- popupItemActionIcon: 'visibility'
- }
+ public usedDescriptionTemplateGroupIdsBySection: Map = new Map;
+ public descriptionTemplateGroupIdsConfigBySection: Map = new Map;
protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeletePlanBlueprint);
@@ -188,6 +180,12 @@ export class PlanBlueprintEditorComponent extends BaseEditor x.hasTemplates == true && x.descriptionTemplates != null && x.descriptionTemplates.length > 0) || [];
+ if (sectionWithDescriptionTemplates.length > 0) {
+ sectionWithDescriptionTemplates.forEach(section => this.descriptionTemplateGroupIdsConfigBySection.set(section.id, this.getdescriptionTemplateGroupSingleAutocompleteConfiguration(section.id)));
+ }
+ }
} catch (error) {
this.logger.error('Could not parse planBlueprint item: ' + data + error);
@@ -424,26 +422,72 @@ export class PlanBlueprintEditorComponent extends BaseEditor this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active], null, null, null, this.getUsedDescriptionTemplateGroupIds(sectionId))).pipe(map(x => x.items)),
+ filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active], searchQuery, null, null, this.getUsedDescriptionTemplateGroupIds(sectionId) ? this.getUsedDescriptionTemplateGroupIds(sectionId) : null)).pipe(map(x => x.items)),
+ getSelectedItem: (selectedItem: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup([IsActive.Active, IsActive.Inactive], null, null, [selectedItem])).pipe(map(x => x.items[0])),
+ displayFn: (item: DescriptionTemplate) => item.label,
+ titleFn: (item: DescriptionTemplate) => item.label,
+ subtitleFn: (item: DescriptionTemplate) => item.description,
+ valueAssign: (item: DescriptionTemplate) => item.groupId,
+ popupItemActionIcon: 'visibility'
+ };
+ }
+
+ getUsedDescriptionTemplateGroupIds(sectionId: Guid): Guid[] {
let excludedGroupIds: Guid[] = [];
(this.formGroup.get('definition').get('sections') as FormArray).controls.forEach((section, index) => {
- const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(index).get('descriptionTemplates') as FormArray;
- if (descriptionTempaltesArray.length > 1) {
- descriptionTempaltesArray.controls.forEach((template, index) => {
- if (template.get('descriptionTemplateGroupId').value != undefined) excludedGroupIds.push(template.get('descriptionTemplateGroupId').value as Guid);
- })
+ if (section.get('id').value === sectionId){
+ if (this.usedDescriptionTemplateGroupIdsBySection.get(sectionId)){
+ excludedGroupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId);
+ } else {
+ this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds);
+ }
+ const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(index).get('descriptionTemplates') as FormArray;
+ if (descriptionTempaltesArray.length > 1) {
+ descriptionTempaltesArray.controls.forEach((template, index) => {
+ if (template.get('descriptionTemplateGroupId').value != undefined && !excludedGroupIds.includes(template.get('descriptionTemplateGroupId').value)) excludedGroupIds.push(template.get('descriptionTemplateGroupId').value as Guid);
+ })
+ this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds);
+ }
}
+
});
return excludedGroupIds;
}
removeDescriptionTemplate(sectionIndex: number, descriptionTemplateIndex: number): void {
+ const sectionId = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('id').value;
+ let groupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId);
+ if (groupIds){
+ const descriptionTemplateGroupId = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray).at(descriptionTemplateIndex).get('descriptionTemplateGroupId').value || null;
+ if (groupIds.includes(descriptionTemplateGroupId)){
+ const index = groupIds.indexOf(descriptionTemplateGroupId, 0);
+ if (index > -1) {
+ groupIds.splice(index, 1);
+ this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, groupIds);
+ }
+ }
+ }
+
const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray;
descriptionTempaltesArray.removeAt(descriptionTemplateIndex);
diff --git a/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts b/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts
index 53cb8b8b2..e555d819a 100644
--- a/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts
+++ b/frontend/src/common/modules/errors/error-handling/http-error-handling.service.ts
@@ -1,6 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
-import { ResponseErrorCode, ResponseErrorCodeHelper } from '@app/core/common/enum/respone-error-code';
+import { ResponseErrorCodeHelper } from '@app/core/common/enum/respone-error-code';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { TranslateService } from '@ngx-translate/core';
@@ -49,16 +49,6 @@ export class HttpErrorHandlingService {
try {
error.errorCode = + errorResponse.error.code;
} catch { }
-
- // if (error && error.error && error.error.error) {
- // errorMsg = error.error.error;
- // // } else if (error && error.message) {
- // // errorMsg = error.message;
- // // } else if (error) {
- // // errorMsg = error;
- // } else {
- // errorMsg = language.instant('COMMONS.ERRORS.DEFAULT');
- // }
return error;
}