11import { DOCUMENT } from '@angular/common' ;
2- import {
3- ComponentFactoryResolver ,
4- ComponentRef ,
5- Inject ,
6- Injectable ,
7- Renderer2 , RendererFactory2
8- } from '@angular/core' ;
2+ import { ComponentFactoryResolver , ComponentRef , Inject , Injectable , Renderer2 , RendererFactory2 } from '@angular/core' ;
93import { OverlayContainerRef } from 'ng-devui/overlay-container' ;
104import { DevConfigService } from 'ng-devui/utils' ;
115import { assign , isUndefined } from 'lodash-es' ;
@@ -19,10 +13,13 @@ export class DialogService {
1913 private renderer : Renderer2 ;
2014 document : Document ;
2115
22- constructor ( private componentFactoryResolver : ComponentFactoryResolver ,
23- private overlayContainerRef : OverlayContainerRef , private rendererFactory : RendererFactory2 ,
24- private devConfigService : DevConfigService ,
25- @Inject ( DOCUMENT ) private doc : any ) {
16+ constructor (
17+ private componentFactoryResolver : ComponentFactoryResolver ,
18+ private overlayContainerRef : OverlayContainerRef ,
19+ private rendererFactory : RendererFactory2 ,
20+ private devConfigService : DevConfigService ,
21+ @Inject ( DOCUMENT ) private doc : any
22+ ) {
2623 this . renderer = this . rendererFactory . createRenderer ( null , null ) ;
2724 this . document = this . doc ;
2825 }
@@ -48,6 +45,7 @@ export class DialogService {
4845 componentFactoryResolver,
4946 beforeHidden,
5047 onClose,
48+ onMaximize,
5149 dialogtype = 'standard' ,
5250 showCloseBtn = true ,
5351 draggable = true ,
@@ -56,7 +54,8 @@ export class DialogService {
5654 offsetY,
5755 bodyScrollable = true ,
5856 contentTemplate,
59- escapable = true
57+ escapable = true ,
58+ showMaximizeBtn = false ,
6059 } : IDialogOptions ) {
6160 const finalComponentFactoryResolver = componentFactoryResolver || this . componentFactoryResolver ;
6261
@@ -95,21 +94,25 @@ export class DialogService {
9594 offsetX,
9695 offsetY,
9796 bodyScrollable,
98- escapable
97+ escapable,
9998 } ) ;
10099
101- const modalContainerRef = modalRef . instance . modalContainerHost . viewContainerRef
102- . createComponent ( finalComponentFactoryResolver . resolveComponentFactory ( ModalContainerComponent ) , 0 , injector ) ;
103- assign ( modalContainerRef . instance , { title, buttons, maxHeight, dialogtype, showCloseBtn } ) ;
100+ const modalContainerRef = modalRef . instance . modalContainerHost . viewContainerRef . createComponent (
101+ finalComponentFactoryResolver . resolveComponentFactory ( ModalContainerComponent ) ,
102+ 0 ,
103+ injector
104+ ) ;
105+ assign ( modalContainerRef . instance , { title, buttons, maxHeight, dialogtype, showCloseBtn, showMaximizeBtn } ) ;
104106
105107 if ( contentTemplate ) {
106108 assign ( modalContainerRef . instance , { contentTemplate } ) ;
107109 } else {
108110 if ( typeof content === 'string' ) {
109111 assign ( modalContainerRef . instance , { content, html } ) ;
110112 } else {
111- this . contentRef = modalContainerRef . instance . modalContentHost . viewContainerRef
112- . createComponent ( finalComponentFactoryResolver . resolveComponentFactory ( content ) ) ;
113+ this . contentRef = modalContainerRef . instance . modalContentHost . viewContainerRef . createComponent (
114+ finalComponentFactoryResolver . resolveComponentFactory ( content )
115+ ) ;
113116 assign ( this . contentRef . instance , { data, dialogtype } ) ;
114117 }
115118 }
@@ -118,7 +121,14 @@ export class DialogService {
118121 modalRef . instance . hide ( ) ;
119122 } ;
120123
121- modalRef . instance . updateButtonOptions = buttonOptions => modalContainerRef . instance . updateButtonOptions ( buttonOptions ) ;
124+ modalContainerRef . instance . onMaximize = ( ) => {
125+ modalRef . instance . maximize ( ) ;
126+ if ( onMaximize ) {
127+ onMaximize ( modalRef . instance . maximized ) ;
128+ }
129+ } ;
130+
131+ modalRef . instance . updateButtonOptions = ( buttonOptions ) => modalContainerRef . instance . updateButtonOptions ( buttonOptions ) ;
122132
123133 modalRef . instance . onHidden = ( ) => {
124134 if ( modalRef . instance . documentOverFlow ) {
0 commit comments