@@ -37,14 +37,19 @@ import {
3737 VerticalAlignment ,
3838 THEME_TOKEN ,
3939 ThemeToken ,
40- IgxGridToolbarDirective
40+ IgxGridToolbarDirective ,
41+ OverlaySettings ,
42+ IgxStringFilteringOperand ,
43+ IFilteringOperation
4144} from 'igniteui-angular' ;
45+ import { fadeIn } from 'igniteui-angular/animations'
4246import { IgxSparklineModule } from 'igniteui-angular-charts' ;
4347import { defineComponents , IgcRatingComponent } from 'igniteui-webcomponents' ;
4448import { dropbox , delivery , billPaid , check } from '@igniteui/material-icons-extended' ;
4549import { OrderDetails , OrderStatus , TemplateDataModel } from '../data/dataModels' ;
4650import { SalesTrendsChartComponent } from '../sales-trends-chart/sales-trends-chart.component' ;
4751import { ErpDataService } from '../services/erp-data.service' ;
52+ import { useAnimation } from '@angular/animations' ;
4853
4954defineComponents ( IgcRatingComponent ) ;
5055
@@ -99,6 +104,8 @@ export class ErpHGridSampleComponent implements AfterViewInit {
99104 public rowisland ! : IgxRowIslandComponent ;
100105 @ViewChild ( 'imageElement' , { static : true } ) imageElement ! : ElementRef ;
101106 @ViewChild ( 'imageDialog' , { static : true } ) imageDialog ! : IgxDialogComponent ;
107+ public fullAddressFilteringOperand = FullAddressFilteringOperand . instance ( ) ;
108+ public shortAddressFilteringOperand = new FullAddressFilteringOperand ( true ) ;
102109
103110 public hgridData : TemplateDataModel [ ] ;
104111 public selectionMode : GridSelectionMode = 'multiple' ;
@@ -110,7 +117,6 @@ export class ErpHGridSampleComponent implements AfterViewInit {
110117 ) {
111118 // data
112119 this . hgridData = this . erpDataService . getProducts ( ) ;
113- const x = this . erpDataService . getProductsJson ( ) ;
114120
115121 // Icons used
116122 this . iconService . addSvgIconFromText ( dropbox . name , dropbox . value , 'imx-icons' ) ;
@@ -145,7 +151,11 @@ export class ErpHGridSampleComponent implements AfterViewInit {
145151 }
146152
147153 public formatAddress ( value : OrderDetails ) : string {
148- return `${ value . streetName } ${ value . streetNumber } ` ;
154+ return `${ value . streetNumber } ${ value . streetName } ` ;
155+ }
156+
157+ public formatFullAddress ( value : OrderDetails ) : string {
158+ return `${ value . streetNumber } ${ value . streetName } , ${ value . zipCode } ${ value . city } , ${ value . country } ` ;
149159 }
150160
151161 public formatNumberAsIs ( value : number ) : number {
@@ -162,19 +172,25 @@ export class ErpHGridSampleComponent implements AfterViewInit {
162172 }
163173
164174 public onImageHover ( event : MouseEvent , dialog : IgxDialogComponent ) {
165- if ( dialog ) {
175+ if ( dialog ) {
166176 const targetEl = event . target as HTMLElement ;
167177
168178 const positionSettings : PositionSettings = {
179+ openAnimation : useAnimation ( fadeIn , {
180+ params : {
181+ delay : '400ms'
182+ }
183+ } ) ,
169184 horizontalStartPoint : HorizontalAlignment . Right ,
170185 verticalStartPoint : VerticalAlignment . Top
171186 } ;
172187
173- dialog . open ( {
188+ const overlaySettings : OverlaySettings = {
174189 target : targetEl ,
175190 modal : false ,
176191 positionStrategy : new AutoPositionStrategy ( positionSettings )
177- } ) ;
192+ }
193+ dialog . open ( overlaySettings ) ;
178194 }
179195 }
180196
@@ -184,3 +200,102 @@ export class ErpHGridSampleComponent implements AfterViewInit {
184200 }
185201 }
186202}
203+
204+ export class FullAddressFilteringOperand extends IgxStringFilteringOperand {
205+ public constructor ( isAddressShort : boolean = false ) {
206+ super ( ) ;
207+ const getShortAddress = ( target : any ) => `${ target . streetNumber } ${ target . streetName } ` ;
208+ const getFullAddress = ( target : any ) => `${ target . streetNumber } ${ target . streetName } , ${ target . zipCode } ${ target . city } , ${ target . country } ` ;
209+
210+ // Rewriting filtering operations to work on the address field
211+ // as it is an object with properties
212+ // and we can't filter it like a normal string field
213+ const customOperations : IFilteringOperation [ ] = [
214+ {
215+ iconName : 'filter_contains' ,
216+ isUnary : false ,
217+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
218+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
219+ ignoreCase = true ;
220+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
221+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
222+ return target . indexOf ( search ) !== - 1 ;
223+ } ,
224+ name : 'Contains'
225+ } ,
226+ {
227+ iconName : 'filter_does_not_contain' ,
228+ isUnary : false ,
229+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
230+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
231+ ignoreCase = true ;
232+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
233+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
234+ return target . indexOf ( search ) === - 1 ;
235+ } ,
236+ name : 'Does Not Contain'
237+ } ,
238+ {
239+ iconName : 'filter_starts_with' ,
240+ isUnary : false ,
241+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
242+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
243+ ignoreCase = true ;
244+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
245+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
246+ return target . startsWith ( search ) ;
247+ } ,
248+ name : 'Starts With'
249+ } ,
250+ {
251+ iconName : 'filter_ends_with' ,
252+ isUnary : false ,
253+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
254+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
255+ ignoreCase = true ;
256+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
257+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
258+ return target . endsWith ( search ) ;
259+ } ,
260+ name : 'Ends With'
261+ } ,
262+ {
263+ iconName : 'filter_equal' ,
264+ isUnary : false ,
265+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
266+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
267+ ignoreCase = true ;
268+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
269+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
270+ return target === search ;
271+ } ,
272+ name : 'Equals'
273+ } ,
274+ {
275+ iconName : 'filter_not_equal' ,
276+ isUnary : false ,
277+ logic : ( target : any , searchVal : string , ignoreCase ?: boolean ) => {
278+ const address = isAddressShort ? getShortAddress ( target ) : getFullAddress ( target ) ;
279+ ignoreCase = true ;
280+ const search = IgxStringFilteringOperand . applyIgnoreCase ( searchVal , ignoreCase ) ;
281+ target = IgxStringFilteringOperand . applyIgnoreCase ( address , ignoreCase ) ;
282+ return target !== search ;
283+ } ,
284+ name : 'Does Not Equal'
285+ } ,
286+ ] ;
287+
288+ const emptyOperators = [
289+ // 'Empty'
290+ this . operations [ 6 ] ,
291+ // 'Not Empty'
292+ this . operations [ 7 ] ,
293+ // 'Null'
294+ this . operations [ 8 ] ,
295+ // 'Not Null'
296+ this . operations [ 9 ] ,
297+ ] ;
298+
299+ this . operations = customOperations . concat ( emptyOperators ) ;
300+ }
301+ }
0 commit comments