diff --git a/libs/portal-integration-angular/src/lib/services/portal-dialog.service.ts b/libs/portal-integration-angular/src/lib/services/portal-dialog.service.ts index 507c76ce..1c7a8743 100644 --- a/libs/portal-integration-angular/src/lib/services/portal-dialog.service.ts +++ b/libs/portal-integration-angular/src/lib/services/portal-dialog.service.ts @@ -7,6 +7,7 @@ import { ButtonDialogComponent } from '../core/components/button-dialog/button-d import { ButtonDialogButtonDetails, ButtonDialogData } from '../model/button-dialog' import { DialogMessageContentComponent } from '../core/components/button-dialog/dialog-message-content/dialog-message-content.component' import { PrimeIcon } from '@onecx/angular-accelerator' +import { string } from 'zod' /** * Object containing key for translation with parameters object for translation @@ -208,6 +209,31 @@ export type DialogState = { result: T | undefined } +export type PortalDialogConfig = { + showXButton?: boolean + ariaLabelledBy?: string + width?: string + height?: string + closeOnEscape?: boolean + focusOnShow?: boolean + focusTrap?: boolean + baseZIndex?: number + autoZIndex?: boolean + dismissableMask?: boolean + showHeader?: boolean + modal?: boolean + resizable?: boolean + draggable?: boolean + keepInViewport?: boolean + minX?: number + minY?: number + maximizable?: boolean + maximizeIcon?: string + minimizeIcon?: string + position?: string + closeAriaLabel?: string +} + @Injectable({ providedIn: 'any' }) export class PortalDialogService { constructor(private dialogService: DialogService, private translateService: TranslateService) {} @@ -366,8 +392,31 @@ export class PortalDialogService { componentOrMessage: Type | Type> | Component | TranslationKey | DialogMessage, primaryButtonTranslationKeyOrDetails: TranslationKey | ButtonDialogButtonDetails, secondaryButtonTranslationKeyOrDetails?: TranslationKey | ButtonDialogButtonDetails, - showXButton: boolean = true + extras?: PortalDialogConfig + ): Observable> + /** + * @deprecated Use `extras` instead + */ + openDialog( + title: TranslationKey | null, + componentOrMessage: Type | Type> | Component | TranslationKey | DialogMessage, + primaryButtonTranslationKeyOrDetails: TranslationKey | ButtonDialogButtonDetails, + secondaryButtonTranslationKeyOrDetails?: TranslationKey | ButtonDialogButtonDetails, + showXButton?: boolean + ): Observable> + openDialog( + title: TranslationKey | null, + componentOrMessage: Type | Type> | Component | TranslationKey | DialogMessage, + primaryButtonTranslationKeyOrDetails: TranslationKey | ButtonDialogButtonDetails, + secondaryButtonTranslationKeyOrDetails?: TranslationKey | ButtonDialogButtonDetails, + extrasOrShowXButton: PortalDialogConfig | boolean = {} ): Observable> { + const dialogOptions: PortalDialogConfig = + typeof extrasOrShowXButton === 'object' + ? extrasOrShowXButton + : { + showXButton: extrasOrShowXButton, + } const translateParams = this.prepareTitleForTranslation(title) const componentToRender: Component = this.getComponentToRender(componentOrMessage) @@ -386,7 +435,8 @@ export class PortalDialogService { return this.dialogService.open(ButtonDialogComponent, { header: dialogTitle, data: dynamicDialogDataConfig, - closable: showXButton && secondaryButtonTranslationKeyOrDetails !== undefined, + closable: dialogOptions.showXButton && secondaryButtonTranslationKeyOrDetails !== undefined, + ...dialogOptions, }).onClose }) )