description template preview select button fix

This commit is contained in:
amentis 2024-04-11 14:20:06 +03:00
parent 39ea1b6c88
commit c11966f658
4 changed files with 17 additions and 33 deletions

View File

@ -77,7 +77,7 @@ export class DescriptionTemplatePreviewDialogComponent extends BaseComponent imp
} }
select(): void { select(): void {
this.dialogRef.close(true); this.dialogRef.close(this.descriptionTemplate.groupId);
} }
closeDialog(): void { closeDialog(): void {

View File

@ -244,7 +244,7 @@
<div class="col-12 col-lg-6 col-xl-3"> <div class="col-12 col-lg-6 col-xl-3">
<mat-form-field class="w-100 mt-3"> <mat-form-field class="w-100 mt-3">
<mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATE' | translate}}</mat-label> <mat-label>{{'DMP-BLUEPRINT-EDITOR.FIELDS.DESCRIPTION-TEMPLATE' | translate}}</mat-label>
<app-single-auto-complete [formControl]="descriptionTemplate.get('descriptionTemplateGroupId')" [hidePlaceholder]="true" [configuration]="descriptionTempalteGroupSingleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)"></app-single-auto-complete> <app-single-auto-complete [formControl]="descriptionTemplate.get('descriptionTemplateGroupId')" [hidePlaceholder]="true" [configuration]="descriptionTempalteGroupSingleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, sectionIndex, descriptionTemplateIndex)"></app-single-auto-complete>
<mat-error *ngIf="descriptionTemplate.get('descriptionTemplateGroupId').hasError('backendError')">{{descriptionTemplate.get('descriptionTemplateGroupId').getError('backendError').message}}</mat-error> <mat-error *ngIf="descriptionTemplate.get('descriptionTemplateGroupId').hasError('backendError')">{{descriptionTemplate.get('descriptionTemplateGroupId').getError('backendError').message}}</mat-error>
<mat-error *ngIf="descriptionTemplate.get('descriptionTemplateGroupId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="descriptionTemplate.get('descriptionTemplateGroupId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { FormArray, UntypedFormGroup } from '@angular/forms'; import { FormArray, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service';
@ -464,7 +464,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
} }
onPreviewDescriptionTemplate(event: DescriptionTemplate, sectionId: Guid) { onPreviewDescriptionTemplate(event: DescriptionTemplate, sectionIndex: number, descriptionTemplateIndex: number) {
const dialogRef = this.dialog.open(DescriptionTemplatePreviewDialogComponent, { const dialogRef = this.dialog.open(DescriptionTemplatePreviewDialogComponent, {
width: '590px', width: '590px',
minHeight: '200px', minHeight: '200px',
@ -474,24 +474,10 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
}, },
panelClass: 'custom-modalbox' panelClass: 'custom-modalbox'
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(groupId => {
// if (result) { if (groupId){
// let blueprints = this.sectionsArray().at(sectionIndex).get('descriptionTemplates').value;//this.formGroup.get('blueprints').value; ((this.formGroup.get('definition').get('sections') as UntypedFormArray).at(sectionIndex).get('descriptionTemplates') as UntypedFormArray).at(descriptionTemplateIndex).get('descriptionTemplateGroupId').patchValue(groupId);
// const blueprint: DescriptionTemplatesInSectionEditor = new DescriptionTemplatesInSectionEditor(); }
// blueprint.id = Guid.create().toString();
// blueprint.descriptionTemplateId = event.id;
// blueprint.label = event.label;
// blueprints.push(blueprint.buildForm());
// this.sectionsArray().at(sectionIndex).get('descriptionTemplates').setValue(blueprints);//this.formGroup.get('blueprints').setValue(blueprints);
// this.blueprintsAutoCompleteConfiguration = {
// filterFn: this.filterProfiles.bind(this),
// initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
// displayFn: (item) => item['label'],
// titleFn: (item) => item['label'],
// subtitleFn: (item) => item['description'],
// popupItemActionIcon: 'visibility'
// };
// }
}); });
} }

View File

@ -501,17 +501,15 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
}, },
panelClass: 'custom-modalbox' panelClass: 'custom-modalbox'
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(groupId => {
if (result) { if (groupId) {
// this.addProfile(event, sectionIndex); let data = this.formGroup.get('descriptionTemplates').get(sectionId.toString()).value as Guid[];
// this.profilesAutoCompleteConfiguration = { if (data){
// filterFn: this.filterProfiles.bind(this), data.push(groupId);
// initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue(data);
// displayFn: (item) => item['label'], } else{
// titleFn: (item) => item['label'], this.formGroup.get('descriptionTemplates').get(sectionId.toString()).patchValue([groupId]);
// subtitleFn: (item) => item['description'], }
// popupItemActionIcon: 'visibility'
// };
} }
}); });
} }