1- import { Component , Input , ChangeDetectorRef , ViewChild , AfterViewInit , TemplateRef , ViewChildren , QueryList , ElementRef , inject } from '@angular/core' ;
2- import { IgxFilteringService } from '../grid-filtering.service' ;
3- import { ILogicOperatorChangedArgs , IgxExcelStyleDefaultExpressionComponent } from './excel-style-default-expression.component' ;
4- import { IgxExcelStyleDateExpressionComponent } from './excel-style-date-expression.component' ;
5- import { ExpressionUI } from './common' ;
61import { NgClass } from '@angular/common' ;
7- import { BaseFilteringComponent } from './base-filtering.component' ;
8- import { IgxButtonDirective , IgxToggleDirective } from 'igniteui-angular/directives' ;
2+ import { ChangeDetectorRef , Component , ElementRef , Input , QueryList , TemplateRef , ViewChild , ViewChildren , inject } from '@angular/core' ;
3+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
4+ import { ColumnType , FilteringLogic , GridColumnDataType , IgxBooleanFilteringOperand , IgxDateFilteringOperand , IgxDateTimeFilteringOperand , IgxNumberFilteringOperand , IgxOverlayService , IgxStringFilteringOperand , IgxTimeFilteringOperand , PlatformUtil } from 'igniteui-angular/core' ;
5+ import { IgxButtonDirective } from 'igniteui-angular/directives' ;
96import { IgxIconComponent } from 'igniteui-angular/icon' ;
10- import { AbsoluteScrollStrategy , AutoPositionStrategy , ColumnType , FilteringLogic , GridColumnDataType , HorizontalAlignment , IgxBooleanFilteringOperand , IgxDateFilteringOperand , IgxDateTimeFilteringOperand , IgxNumberFilteringOperand , IgxOverlayService , IgxStringFilteringOperand , IgxTimeFilteringOperand , OverlaySettings , PlatformUtil , PositionSettings , VerticalAlignment } from 'igniteui-angular/core' ;
7+ import { IgxFilteringService } from '../grid-filtering.service' ;
8+ import { BaseFilteringComponent } from './base-filtering.component' ;
9+ import { ExpressionUI } from './common' ;
10+ import { IgxExcelStyleDateExpressionComponent } from './excel-style-date-expression.component' ;
11+ import { ILogicOperatorChangedArgs , IgxExcelStyleDefaultExpressionComponent } from './excel-style-default-expression.component' ;
1112
1213/**
1314 * @hidden
1415 */
1516@Component ( {
1617 selector : 'igx-excel-style-custom-dialog' ,
1718 templateUrl : './excel-style-custom-dialog.component.html' ,
18- imports : [ IgxToggleDirective , NgClass , IgxExcelStyleDateExpressionComponent , IgxExcelStyleDefaultExpressionComponent , IgxButtonDirective , IgxIconComponent ]
19+ imports : [ NgClass , IgxExcelStyleDateExpressionComponent , IgxExcelStyleDefaultExpressionComponent , IgxButtonDirective , IgxIconComponent ]
1920} )
20- export class IgxExcelStyleCustomDialogComponent implements AfterViewInit {
21+ export class IgxExcelStyleCustomDialogComponent {
2122 protected overlayService = inject ( IgxOverlayService ) ;
2223 private cdr = inject ( ChangeDetectorRef ) ;
2324 protected platform = inject ( PlatformUtil ) ;
24- public esf = inject ( BaseFilteringComponent ) ;
25+ public esf ?: BaseFilteringComponent ;
26+
27+ constructor ( ) {
28+ this . overlayService . opening . pipe ( takeUntilDestroyed ( ) ) . subscribe ( ( args ) => {
29+ if ( args . id === this . overlayComponentId )
30+ this . onCustomDialogOpening ( ) ;
31+ } ) ;
32+ this . overlayService . opened . pipe ( takeUntilDestroyed ( ) ) . subscribe ( ( args ) => {
33+ if ( args . id === this . overlayComponentId )
34+ this . onCustomDialogOpened ( ) ;
35+ } ) ;
36+
37+ this . overlayService . closed . pipe ( takeUntilDestroyed ( ) ) . subscribe ( ( args ) => {
38+ if ( args . id === this . overlayComponentId ) {
39+ this . overlayService . detach ( this . overlayComponentId ) ;
40+ this . overlayComponentId = null ;
41+ }
42+ } ) ;
43+ }
2544
2645 @Input ( )
2746 public expressionsList = new Array < ExpressionUI > ( ) ;
@@ -38,9 +57,6 @@ export class IgxExcelStyleCustomDialogComponent implements AfterViewInit {
3857 @Input ( )
3958 public overlayComponentId : string ;
4059
41- @ViewChild ( 'toggle' , { read : IgxToggleDirective , static : true } )
42- public toggle : IgxToggleDirective ;
43-
4460 @ViewChild ( 'defaultExpressionTemplate' , { read : TemplateRef } )
4561 protected defaultExpressionTemplate : TemplateRef < any > ;
4662
@@ -56,24 +72,6 @@ export class IgxExcelStyleCustomDialogComponent implements AfterViewInit {
5672 @ViewChildren ( IgxExcelStyleDateExpressionComponent )
5773 private expressionDateComponents : QueryList < IgxExcelStyleDateExpressionComponent > ;
5874
59- private _customDialogPositionSettings : PositionSettings = {
60- verticalDirection : VerticalAlignment . Middle ,
61- horizontalDirection : HorizontalAlignment . Center ,
62- horizontalStartPoint : HorizontalAlignment . Center ,
63- verticalStartPoint : VerticalAlignment . Middle
64- } ;
65-
66- private _customDialogOverlaySettings : OverlaySettings = {
67- closeOnOutsideClick : true ,
68- modal : false ,
69- positionStrategy : new AutoPositionStrategy ( this . _customDialogPositionSettings ) ,
70- scrollStrategy : new AbsoluteScrollStrategy ( )
71- } ;
72-
73- public ngAfterViewInit ( ) : void {
74- this . _customDialogOverlaySettings . outlet = this . grid . outlet ;
75- }
76-
7775 public get template ( ) : TemplateRef < any > {
7876 if ( this . column . dataType === GridColumnDataType . Date ) {
7977 return this . dateExpressionTemplate ;
@@ -98,15 +96,6 @@ export class IgxExcelStyleCustomDialogComponent implements AfterViewInit {
9896 }
9997 }
10098
101- public open ( esf ) {
102- this . _customDialogOverlaySettings . target =
103- this . overlayComponentId ?
104- this . grid . rootGrid ? this . grid . rootGrid . nativeElement : this . grid . nativeElement :
105- esf ;
106- this . toggle . open ( this . _customDialogOverlaySettings ) ;
107- this . overlayComponentId = this . toggle . overlayId ;
108- }
109-
11099 public onClearButtonClick ( ) {
111100 this . filteringService . clearFilter ( this . column . field ) ;
112101 this . selectedOperator = null ;
@@ -117,14 +106,13 @@ export class IgxExcelStyleCustomDialogComponent implements AfterViewInit {
117106 public closeDialog ( ) {
118107 if ( this . overlayComponentId ) {
119108 this . overlayService . hide ( this . overlayComponentId ) ;
109+ this . overlayService . detach ( this . overlayComponentId ) ;
120110 this . overlayComponentId = null ;
121- } else {
122- this . toggle . close ( ) ;
123111 }
124112 }
125113
126114 public cancelDialog ( ) {
127- this . esf . cancel ( ) ;
115+ this . esf ? .cancel ( ) ;
128116 this . closeDialog ( ) ;
129117 }
130118
0 commit comments