From 17f71b118f5185ef6e013eeb3f64d43700c79cdb Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 9 Jul 2024 16:20:43 +0300 Subject: [PATCH] add preview description template on plan upload dialog --- .../services/plan/plan-blueprint.service.ts | 2 +- .../plan-upload-dialog.component.html | 2 +- .../plan-upload-dialog.component.ts | 19 +++++++++++++++++++ .../plan-upload-dialog.module.ts | 4 +++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/core/services/plan/plan-blueprint.service.ts b/frontend/src/app/core/services/plan/plan-blueprint.service.ts index ef60165d0..5841a8e44 100644 --- a/frontend/src/app/core/services/plan/plan-blueprint.service.ts +++ b/frontend/src/app/core/services/plan/plan-blueprint.service.ts @@ -149,7 +149,7 @@ export class PlanBlueprintService { filterFn: (searchQuery: string, data?: any) => this.query(this.buildAutocompleteWithDefinitonLookup(searchQuery, null, null, [PlanBlueprintStatus.Finalized])).pipe(map(x => x.items)), getSelectedItem: (selectedItem: any) => this.query(this.buildAutocompleteWithDefinitonLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])), displayFn: (item: PlanBlueprint) => item.label, - subtitleFn: (item: PlanBlueprint) => this.language.instant('Plan-EDITOR.FIELDS.Plan-BLUEPRINT-VERSION') + ' '+ item.version, + subtitleFn: (item: PlanBlueprint) => this.language.instant('PLAN-EDITOR.FIELDS.PLAN-BLUEPRINT-VERSION') + ' '+ item.version, titleFn: (item: PlanBlueprint) => item.label, valueAssign: (item: PlanBlueprint) => item.id, }; diff --git a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.html b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.html index 885238c93..3fab18a32 100644 --- a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.html +++ b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.html @@ -54,7 +54,7 @@
{{'PLAN-UPLOAD.FIELDS.DESCRIPTION-TEMPLATE' | translate}} - + {{description.get('templateId').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} diff --git a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.ts b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.ts index ce9d25507..5d4486961 100644 --- a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.ts +++ b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.component.ts @@ -18,6 +18,8 @@ import { IsActive } from '@notification-service/core/enum/is-active.enum'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { TranslateService } from '@ngx-translate/core'; +import { Guid } from '@common/types/guid'; +import { DescriptionTemplatePreviewDialogComponent } from '@app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component'; @Component({ selector: 'plan-upload-dialog', @@ -162,6 +164,23 @@ export class PlanUploadDialogComponent extends BaseComponent { } } + onPreviewDescriptionTemplate(event, descriptionIndex: number) { + const dialogRef = this.dialog.open(DescriptionTemplatePreviewDialogComponent, { + width: '590px', + minHeight: '200px', + restoreFocus: false, + data: { + descriptionTemplateId: event.id + }, + panelClass: 'custom-modalbox' + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(groupId => { + if (groupId) { + (this.formGroup.get('descriptions') as UntypedFormArray).at(descriptionIndex).get('templateId').patchValue(event.id); + } + }); + } + hasFile(): boolean { return this.files && this.files.length > 0; } diff --git a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.module.ts b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.module.ts index addada799..b3fdc4554 100644 --- a/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.module.ts +++ b/frontend/src/app/ui/plan/new/upload-dialogue/plan-upload-dialog.module.ts @@ -6,6 +6,7 @@ import { NgxDropzoneModule } from 'ngx-dropzone'; import { PlanUploadDialogComponent } from './plan-upload-dialog.component'; import { ReactiveFormsModule } from '@angular/forms'; import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.module'; +import { DescriptionTemplatePreviewDialogModule } from '@app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.module'; @NgModule({ imports: [ @@ -14,7 +15,8 @@ import { AutoCompleteModule } from '@app/library/auto-complete/auto-complete.mod FormattingModule, ReactiveFormsModule, AutoCompleteModule, - NgxDropzoneModule + NgxDropzoneModule, + DescriptionTemplatePreviewDialogModule ], declarations: [ PlanUploadDialogComponent,