format (no changes)

This commit is contained in:
CITE\spapacharalampous 2024-09-09 12:50:38 +03:00
parent ec1410c23e
commit aeefa6cfc4
2 changed files with 127 additions and 132 deletions

View File

@ -3,7 +3,7 @@
<div class="col-md-10 offset-md-1"> <div class="col-md-10 offset-md-1">
<div class="row align-items-center mt-4 mb-4" *ngIf="formGroup"> <div class="row align-items-center mt-4 mb-4" *ngIf="formGroup">
<div class="col-md col-12"> <div class="col-md col-12">
<app-navigation-breadcrumb /> <app-navigation-breadcrumb />
</div> </div>
<div class="col-md-auto mb-md-0 col-12 mb-2" *ngIf="canDelete"> <div class="col-md-auto mb-md-0 col-12 mb-2" *ngIf="canDelete">
<button [disabled]="isLocked" mat-button class="rounded-btn secondary" type="button" (click)="delete()"> <button [disabled]="isLocked" mat-button class="rounded-btn secondary" type="button" (click)="delete()">
@ -98,12 +98,12 @@
</div> </div>
</div> </div>
<div class="col-auto pr-0 section-options-horizontal"> <div class="col-auto pr-0 section-options-horizontal">
<span *ngIf="!isSectionSelected(fieldIndex)" style="font-size: 18px; box-sizing: border-box; display: inline-block; padding: 0.85rem 0.45rem;">{{fieldIndex + 1}}</span> <span *ngIf="!isSectionSelected(fieldIndex)" style="font-size: 18px; box-sizing: border-box; display: inline-block; padding: 0.85rem 0.45rem;">{{fieldIndex + 1}}</span>
<mat-icon *ngIf="isSectionSelected(fieldIndex)" [ngClass]="{'drag-handle-disabled': hideEditActions}" cdkDragHandle class="drag-handle">drag_indicator</mat-icon> <mat-icon *ngIf="isSectionSelected(fieldIndex)" [ngClass]="{'drag-handle-disabled': hideEditActions}" cdkDragHandle class="drag-handle">drag_indicator</mat-icon>
</div> </div>
<div class="col"> <div class="col">
<div class="row align-items-center"> <div class="row align-items-center">
<!-- FIELD TYPE --> <!-- FIELD TYPE -->
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}}</mat-label>
@ -114,101 +114,97 @@
<mat-error *ngIf="field.get('category').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('category').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@switch(field.get('category').value){ @switch(field.get('category').value){
@case(planBlueprintSectionFieldCategory.System){ @case(planBlueprintSectionFieldCategory.System){
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label>
<mat-select [formControl]="field.get('systemFieldType')"> <mat-select [formControl]="field.get('systemFieldType')">
<mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option> <mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('systemFieldType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('systemFieldType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
} }
@case(planBlueprintSectionFieldCategory.Extra){ @case(planBlueprintSectionFieldCategory.Extra){
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
<mat-select [formControl]="field.get('dataType')"> <mat-select [formControl]="field.get('dataType')">
<mat-option *ngFor="let extraFieldDataType of planBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType"> <mat-option *ngFor="let extraFieldDataType of planBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType">
{{enumUtils.toPlanBlueprintExtraFieldDataTypeString(extraFieldDataType)}} {{enumUtils.toPlanBlueprintExtraFieldDataTypeString(extraFieldDataType)}}
</mat-option> </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="field.get('dataType').hasError('backendError')">{{field.get('dataType').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('dataType').hasError('backendError')">{{field.get('dataType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('dataType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('dataType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
} }
@case(planBlueprintSectionFieldCategory.ReferenceType){ @case(planBlueprintSectionFieldCategory.ReferenceType){
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
<app-single-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete> <app-single-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
<mat-error *ngIf="field.get('referenceTypeId').hasError('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('referenceTypeId').hasError('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
} }
} }
@if(field.get('category').value != null){ @if(field.get('category').value != null){
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label>
<input matInput type="text" name="label" [formControl]="field.get('label')"> <input matInput type="text" name="label" [formControl]="field.get('label')">
<mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-PLACEHOLDER' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-PLACEHOLDER' | translate}}</mat-label>
<input matInput type="text" name="placeholder" [formControl]="field.get('placeholder')"> <input matInput type="text" name="placeholder" [formControl]="field.get('placeholder')">
<mat-error *ngIf="field.get('placeholder').hasError('backendError')">{{field.get('placeholder').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('placeholder').hasError('backendError')">{{field.get('placeholder').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('placeholder').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('placeholder').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-12 col-xl-4"> <div class="col-12 col-xl-4">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-DESCRIPTION' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-DESCRIPTION' | translate}}</mat-label>
<input matInput type="text" name="description" [formControl]="field.get('description')"> <input matInput type="text" name="description" [formControl]="field.get('description')">
<mat-error *ngIf="field.get('description').hasError('backendError')">{{field.get('description').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('description').hasError('backendError')">{{field.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-12 order-xl-8"> <div class="col-12 order-xl-8">
<mat-form-field class="mt-3 w-100"> <mat-form-field class="mt-3 w-100">
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}</mat-label> <mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}" [required]="false" [separatorKeysCodes]="separatorKeysCodes" [formControl]="field.get('semantics')" [configuration]="semanticsService.multipleAutocompleteConfiguration"> <app-multiple-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}" [required]="false" [separatorKeysCodes]="separatorKeysCodes" [formControl]="field.get('semantics')" [configuration]="semanticsService.multipleAutocompleteConfiguration">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="field.get('semantics').hasError('backendError')">{{field.get('semantics').getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('semantics').hasError('backendError')">{{field.get('semantics').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-auto col-xl-2 section-field"> <div class="col-auto col-xl-2 section-field">
@if (isMandatorySystemField(field?.value)) { @if (isMandatorySystemField(field?.value)) {
<app-noop-checkbox <app-noop-checkbox [control]="field.get('required')" label="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}" tooltipText="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-REQUIRED' | translate}}"></app-noop-checkbox>
[control]="field.get('required')" }
label="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}" @else {
tooltipText="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-REQUIRED' | translate}}" <mat-checkbox [formControl]="field.get('required')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
></app-noop-checkbox> }
} <mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
@else { <mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-checkbox [formControl]="field.get('required')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox> </div>
} }
<mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
}
<div class="col-auto col-xl-2"> <div class="col-auto col-xl-2">
@if(field.get('category').value === planBlueprintSectionFieldCategory.ReferenceType){ @if(field.get('category').value === planBlueprintSectionFieldCategory.ReferenceType){
<div> <div>
<mat-checkbox [formControl]="field.get('multipleSelect')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox> <mat-checkbox [formControl]="field.get('multipleSelect')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox>
<mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error> <mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div> </div>
} }
</div> </div>
</div> </div>
</div> </div>
@ -263,8 +259,8 @@
</div> </div>
</div> </div>
<div class="col-auto pr-0 section-options-horizontal"> <div class="col-auto pr-0 section-options-horizontal">
<span *ngIf="!isDescriptionTemplateSelected(descriptionTemplateIndex)" style="font-size: 18px; box-sizing: border-box; display: inline-block; padding: 0.85rem 0.45rem;">{{descriptionTemplateIndex + 1}}</span> <span *ngIf="!isDescriptionTemplateSelected(descriptionTemplateIndex)" style="font-size: 18px; box-sizing: border-box; display: inline-block; padding: 0.85rem 0.45rem;">{{descriptionTemplateIndex + 1}}</span>
<mat-icon *ngIf="isDescriptionTemplateSelected(descriptionTemplateIndex)" [ngClass]="{'drag-handle-disabled': hideEditActions}" cdkDragHandle class="drag-handle">drag_indicator</mat-icon> <mat-icon *ngIf="isDescriptionTemplateSelected(descriptionTemplateIndex)" [ngClass]="{'drag-handle-disabled': hideEditActions}" cdkDragHandle class="drag-handle">drag_indicator</mat-icon>
</div> </div>
<div class="col"> <div class="col">
@ -364,5 +360,4 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -70,27 +70,27 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
public usedDescriptionTemplateGroupIdsBySection: Map<Guid, Guid[]> = new Map<Guid, Guid[]>; public usedDescriptionTemplateGroupIdsBySection: Map<Guid, Guid[]> = new Map<Guid, Guid[]>;
public descriptionTemplateGroupIdsConfigBySection: Map<Guid, SingleAutoCompleteConfiguration> = new Map<Guid, SingleAutoCompleteConfiguration>; public descriptionTemplateGroupIdsConfigBySection: Map<Guid, SingleAutoCompleteConfiguration> = new Map<Guid, SingleAutoCompleteConfiguration>;
PlanBlueprintStatus = PlanBlueprintStatus; PlanBlueprintStatus = PlanBlueprintStatus;
isNew = true; isNew = true;
isClone = false; isClone = false;
isNewVersion = false; isNewVersion = false;
isDeleted = false; isDeleted = false;
belongsToCurrentTenant = true; belongsToCurrentTenant = true;
protected get isTransient(): boolean { protected get isTransient(): boolean {
return this.isNew || this.isClone || this.isNewVersion; return this.isNew || this.isClone || this.isNewVersion;
} }
protected get hideEditActions(): boolean { protected get hideEditActions(): boolean {
return (this.isDeleted || this.isFinalized || !this.authService.hasPermission(AppPermission.EditPlanBlueprint) || !this.belongsToCurrentTenant) && !this.isNewVersion; return (this.isDeleted || this.isFinalized || !this.authService.hasPermission(AppPermission.EditPlanBlueprint) || !this.belongsToCurrentTenant) && !this.isNewVersion;
} }
protected get canDownloadXML(): boolean { protected get canDownloadXML(): boolean {
return (this.formGroup.get('status').value === PlanBlueprintStatus.Finalized) && !this.isTransient; return (this.formGroup.get('status').value === PlanBlueprintStatus.Finalized) && !this.isTransient;
} }
protected get canDelete(): boolean { protected get canDelete(): boolean {
return !this.isDeleted && !this.isTransient && this.belongsToCurrentTenant && this.hasPermission(this.authService.permissionEnum.DeletePlanBlueprint); return !this.isDeleted && !this.isTransient && this.belongsToCurrentTenant && this.hasPermission(this.authService.permissionEnum.DeletePlanBlueprint);
} }
protected get canFinalize(): boolean { protected get canFinalize(): boolean {
@ -175,14 +175,14 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
.subscribe({ .subscribe({
next: (data) => successFunction(data), next: (data) => successFunction(data),
error: (error) => this.onCallbackError(error) error: (error) => this.onCallbackError(error)
}); });
} }
prepareForm(data: PlanBlueprint) { prepareForm(data: PlanBlueprint) {
try { try {
this.editorModel = data ? new PlanBlueprintEditorModel().fromModel(data) : new PlanBlueprintEditorModel(); this.editorModel = data ? new PlanBlueprintEditorModel().fromModel(data) : new PlanBlueprintEditorModel();
this.isDeleted = data ? data.isActive === IsActive.Inactive : false; this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.belongsToCurrentTenant = this.isNew || data.belongsToCurrentTenant; this.belongsToCurrentTenant = this.isNew || data.belongsToCurrentTenant;
this.buildForm(); this.buildForm();
@ -235,7 +235,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
this.formGroup.get('status').setValue(PlanBlueprintStatus.Draft); this.formGroup.get('status').setValue(PlanBlueprintStatus.Draft);
this.onCallbackError(error); this.onCallbackError(error);
} }
}); });
} else if (!this.isNew && !this.isClone) { } else if (!this.isNew && !this.isClone) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionPlanBlueprintPersist; const formData = this.formService.getValue(this.formGroup.value) as NewVersionPlanBlueprintPersist;
@ -243,7 +243,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
.pipe(takeUntil(this._destroyed)).subscribe({ .pipe(takeUntil(this._destroyed)).subscribe({
next: (complete) => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete), next: (complete) => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error: (error) => this.onCallbackError(error) error: (error) => this.onCallbackError(error)
}); });
} }
} }
@ -410,8 +410,8 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
} }
isMandatorySystemField(field: FieldInSectionEditorModel): boolean { isMandatorySystemField(field: FieldInSectionEditorModel): boolean {
return field != null && return field != null &&
field.category == this.planBlueprintSectionFieldCategory.System && field.category == this.planBlueprintSectionFieldCategory.System &&
this.alwaysRequiredSystemFieldTypes.includes(field.systemFieldType); this.alwaysRequiredSystemFieldTypes.includes(field.systemFieldType);
} }
@ -448,11 +448,11 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
} }
} }
selectedDescriptionTemplate(descriptionTemplate: DescriptionTemplate, sectionId: Guid){ selectedDescriptionTemplate(descriptionTemplate: DescriptionTemplate, sectionId: Guid) {
let excludedGroupIds: Guid[] = []; let excludedGroupIds: Guid[] = [];
if (this.usedDescriptionTemplateGroupIdsBySection.get(sectionId)){ if (this.usedDescriptionTemplateGroupIdsBySection.get(sectionId)) {
excludedGroupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId); excludedGroupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId);
} }
if (!excludedGroupIds.includes(descriptionTemplate.groupId)) excludedGroupIds.push(descriptionTemplate.groupId); if (!excludedGroupIds.includes(descriptionTemplate.groupId)) excludedGroupIds.push(descriptionTemplate.groupId);
this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds); this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds);
} }
@ -480,8 +480,8 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
getUsedDescriptionTemplateGroupIds(sectionId: Guid): Guid[] { getUsedDescriptionTemplateGroupIds(sectionId: Guid): Guid[] {
let excludedGroupIds: Guid[] = []; let excludedGroupIds: Guid[] = [];
(this.formGroup.get('definition').get('sections') as FormArray).controls.forEach((section, index) => { (this.formGroup.get('definition').get('sections') as FormArray).controls.forEach((section, index) => {
if (section.get('id').value === sectionId){ if (section.get('id').value === sectionId) {
if (this.usedDescriptionTemplateGroupIdsBySection.get(sectionId)){ if (this.usedDescriptionTemplateGroupIdsBySection.get(sectionId)) {
excludedGroupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId); excludedGroupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId);
} else { } else {
this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds); this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds);
@ -494,7 +494,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds); this.usedDescriptionTemplateGroupIdsBySection.set(sectionId, excludedGroupIds);
} }
} }
}); });
return excludedGroupIds; return excludedGroupIds;
@ -503,9 +503,9 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
removeDescriptionTemplate(sectionIndex: number, descriptionTemplateIndex: number): void { removeDescriptionTemplate(sectionIndex: number, descriptionTemplateIndex: number): void {
const sectionId = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('id').value; const sectionId = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('id').value;
let groupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId); let groupIds = this.usedDescriptionTemplateGroupIdsBySection.get(sectionId);
if (groupIds){ if (groupIds) {
const descriptionTemplateGroupId = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray).at(descriptionTemplateIndex).get('descriptionTemplateGroupId').value || null; 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)){ if (groupIds.includes(descriptionTemplateGroupId)) {
const index = groupIds.indexOf(descriptionTemplateGroupId, 0); const index = groupIds.indexOf(descriptionTemplateGroupId, 0);
if (index > -1) { if (index > -1) {
groupIds.splice(index, 1); groupIds.splice(index, 1);
@ -513,7 +513,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
} }
} }
} }
const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray; const descriptionTempaltesArray = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('descriptionTemplates') as FormArray;
descriptionTempaltesArray.removeAt(descriptionTemplateIndex); descriptionTempaltesArray.removeAt(descriptionTemplateIndex);
@ -525,10 +525,10 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
); );
descriptionTempaltesArray.markAsDirty(); descriptionTempaltesArray.markAsDirty();
} }
removePrefillingSources(sectionIndex: number, prefillingSourceIndex: number): void { removePrefillingSources(sectionIndex: number, prefillingSourceIndex: number): void {
const sectionId = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('id').value; const sectionId = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('id').value;
const prefillingSourcesControl = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('prefillingSourcesIds'); const prefillingSourcesControl = (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('prefillingSourcesIds');
prefillingSourcesControl.reset(); prefillingSourcesControl.reset();
@ -646,7 +646,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
finalize() { finalize() {
if (this.checkValidity() || !this.hasDescriptionTemplates()) { if (this.checkValidity() || !this.hasDescriptionTemplates()) {
this.formGroup.get('status').setValue(PlanBlueprintStatus.Finalized); this.formGroup.get('status').setValue(PlanBlueprintStatus.Finalized);
if (this.isNewVersion){ this.isNewVersion = false; } if (this.isNewVersion) { this.isNewVersion = false; }
this.formSubmit(); this.formSubmit();
} }
} }