From 229bc7efd95b76579cc3cbe0dedf5dc9fa5b1402 Mon Sep 17 00:00:00 2001 From: nesgarbo <60317435+nesgarbo@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:10:56 +0100 Subject: [PATCH 1/3] Update dialogservice.ts Extend functionality of dynamic dialog to have inputs --- packages/primeng/src/dynamicdialog/dialogservice.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/primeng/src/dynamicdialog/dialogservice.ts b/packages/primeng/src/dynamicdialog/dialogservice.ts index 8c8b4096d74..04a1c3b5336 100755 --- a/packages/primeng/src/dynamicdialog/dialogservice.ts +++ b/packages/primeng/src/dynamicdialog/dialogservice.ts @@ -26,7 +26,7 @@ export class DialogService { * @returns {DynamicDialogRef} DynamicDialog instance. * @group Method */ - public open(componentType: Type, config: DynamicDialogConfig): DynamicDialogRef { + public open = {}>(componentType: Type, config: DynamicDialogConfig): DynamicDialogRef { if (!this.duplicationPermission(componentType, config)) { return null; } @@ -34,7 +34,8 @@ export class DialogService { const dialogRef = this.appendDialogComponentToBody(config, componentType); this.dialogComponentRefMap.get(dialogRef).instance.childComponentType = componentType; - + this.dialogComponentRefMap.get(dialogRef).instance.inputValues = config.inputValues; + return dialogRef; } /** From f70ae8e187c71eeb40a7cc6a68a7f70f9fee779c Mon Sep 17 00:00:00 2001 From: nesgarbo <60317435+nesgarbo@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:13:17 +0100 Subject: [PATCH 2/3] Update dynamicdialog-config.ts Extend functionality of dynamic dialog to have inputs --- .../primeng/src/dynamicdialog/dynamicdialog-config.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/primeng/src/dynamicdialog/dynamicdialog-config.ts b/packages/primeng/src/dynamicdialog/dynamicdialog-config.ts index c71db273c6d..fc73fb42f93 100755 --- a/packages/primeng/src/dynamicdialog/dynamicdialog-config.ts +++ b/packages/primeng/src/dynamicdialog/dynamicdialog-config.ts @@ -4,12 +4,17 @@ import { Type } from '@angular/core'; * Dialogs can be created dynamically with any component as the content using a DialogService. * @group Components */ -export class DynamicDialogConfig { +export class DynamicDialogConfig = {}> { /** * An object to pass to the component loaded inside the Dialog. * @group Props */ - data?: T; + data?: DataType; + /** + * An object to pass to the component loaded inside the Dialog. + * @group Props + */ + inputValues?: InputValuesType; /** * Header text of the dialog. * @group Props From 2bf3fbe685cf800901d82ca9b396f2326ff014bf Mon Sep 17 00:00:00 2001 From: nesgarbo <60317435+nesgarbo@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:17:24 +0100 Subject: [PATCH 3/3] Update dynamicdialog.ts Extend functionality of dynamic dialog to have inputs --- packages/primeng/src/dynamicdialog/dynamicdialog.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/primeng/src/dynamicdialog/dynamicdialog.ts b/packages/primeng/src/dynamicdialog/dynamicdialog.ts index b6db915e53c..08e3b2ce259 100755 --- a/packages/primeng/src/dynamicdialog/dynamicdialog.ts +++ b/packages/primeng/src/dynamicdialog/dynamicdialog.ts @@ -151,6 +151,8 @@ export class DynamicDialogComponent extends BaseComponent implements AfterViewIn childComponentType: Nullable>; + inputValues: Record; + container: Nullable; wrapper: Nullable; @@ -348,6 +350,13 @@ export class DynamicDialogComponent extends BaseComponent implements AfterViewIn viewContainerRef?.clear(); this.componentRef = viewContainerRef?.createComponent(componentType); + + if (this.inputValues) { + Object.entries(this.inputValues).forEach(([key, value]) => { + this.componentRef.setInput(key, value); + }); + } + this.dialogRef.onChildComponentLoaded.next(this.componentRef!.instance); }