diff --git a/angular/projects/catalyst/src/lib/dialog/dialog.service.ts b/angular/projects/catalyst/src/lib/dialog/dialog.service.ts index 405fb3bd..efdaa10a 100644 --- a/angular/projects/catalyst/src/lib/dialog/dialog.service.ts +++ b/angular/projects/catalyst/src/lib/dialog/dialog.service.ts @@ -1,4 +1,4 @@ -import { Dialog, DialogConfig } from '@angular/cdk/dialog'; +import { Dialog, DialogConfig, DialogRef } from '@angular/cdk/dialog'; import { ComponentType } from '@angular/cdk/portal'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; @@ -31,6 +31,17 @@ export class CatDialogService { component: ComponentType, config?: CatDialogConfig ): Observable { + return this.openWithRef(component, config).closed; + } + + /** + * Opens a modal dialog containing the given component and returns a reference to the dialog. + * + * @param component - The component to render as dialog content. + * @param config - The dialog configuration. + * @returns A reference to the just opened dialog. + */ + openWithRef(component: ComponentType, config?: CatDialogConfig): DialogRef { const panelClass = config?.panelClass ?? []; return this.dialog.open(component, { backdropClass: 'cat-backdrop', @@ -41,7 +52,7 @@ export class CatDialogService { maxHeight: 'calc(100vh - 64px)', maxWidth: 'calc(100vw - 64px)', ...config - }).closed; + }); } /**