11import { Component , CUSTOM_ELEMENTS_SCHEMA , ViewChild , AfterViewInit , ElementRef , OnInit } from '@angular/core' ;
2- import { CommonModule , NgIf } from '@angular/common' ;
2+ import { CommonModule } from '@angular/common' ;
33import {
44 IgxHierarchicalGridComponent ,
55 IgxColumnGroupComponent ,
@@ -46,7 +46,7 @@ import { fadeIn } from 'igniteui-angular/animations'
4646import { IgxSparklineModule } from 'igniteui-angular-charts' ;
4747import { defineComponents , IgcRatingComponent } from 'igniteui-webcomponents' ;
4848import { dropbox , delivery , billPaid , check } from '@igniteui/material-icons-extended' ;
49- import { OrderDetails , OrderStatus , TemplateDataModel } from '../data/dataModels' ;
49+ import { BadgeVariant , OrderDetails , OrderStatus , TemplateDataModel } from '../data/dataModels' ;
5050import { SalesTrendsChartComponent } from '../sales-trends-chart/sales-trends-chart.component' ;
5151import { ErpDataService } from '../services/erp-data.service' ;
5252import { BehaviorSubject } from 'rxjs' ;
@@ -87,7 +87,6 @@ defineComponents(IgcRatingComponent);
8787 IgxIconModule ,
8888 IgxBadgeModule ,
8989 IgxBadgeComponent ,
90- NgIf ,
9190 IgxSparklineModule ,
9291 IgxButtonModule ,
9392 IgxDialogModule ,
@@ -104,7 +103,6 @@ export class ErpHGridSampleComponent implements OnInit, AfterViewInit {
104103 public hierarchicalGrid ! : IgxHierarchicalGridComponent ;
105104 @ViewChild ( 'rowisland' , { read : IgxRowIslandComponent , static : true } )
106105 public rowisland ! : IgxRowIslandComponent ;
107- @ViewChild ( 'imageElement' , { static : true } ) imageElement ! : ElementRef ;
108106 @ViewChild ( 'imageDialog' , { static : true } ) imageDialog ! : IgxDialogComponent ;
109107 public fullAddressFilteringOperand = FullAddressFilteringOperand . instance ( ) ;
110108 public shortAddressFilteringOperand = new FullAddressFilteringOperand ( true ) ;
@@ -115,6 +113,10 @@ export class ErpHGridSampleComponent implements OnInit, AfterViewInit {
115113 public data$ : BehaviorSubject < TemplateDataModel [ ] > = new BehaviorSubject < TemplateDataModel [ ] > ( [ ] ) ;
116114 public isLoading = true ;
117115
116+ // Image tooltip for each product fields
117+ public hoveredImageUrl : string = '' ;
118+ public hoveredImageProductName : string = '' ;
119+
118120 constructor (
119121 private iconService : IgxIconService ,
120122 private erpDataService : ErpDataService
@@ -139,12 +141,6 @@ export class ErpHGridSampleComponent implements OnInit, AfterViewInit {
139141
140142 public ngAfterViewInit ( ) : void {
141143 // Default sortings
142- this . hierarchicalGrid . sortingExpressions = [
143- {
144- dir : SortingDirection . Asc , fieldName : 'sku' ,
145- ignoreCase : true , strategy : DefaultSortingStrategy . instance ( )
146- }
147- ] ;
148144 this . rowisland . sortingExpressions = [
149145 {
150146 dir : SortingDirection . Desc , fieldName : 'delivery.dateOrdered' ,
@@ -158,6 +154,36 @@ export class ErpHGridSampleComponent implements OnInit, AfterViewInit {
158154 'The column is expanded! Click here to collapse.' : 'The column is collapsed! Click here to expand' ;
159155 }
160156
157+ public getOrderStatusBadgeVariant = ( status : string ) : BadgeVariant => {
158+ switch ( status ) {
159+ case OrderStatus . PACKED :
160+ return "primary" ;
161+ case OrderStatus . IN_TRANSIT :
162+ return "warning" ;
163+ case OrderStatus . CUSTOMS :
164+ return "error" ;
165+ case OrderStatus . DELIVERED :
166+ return "success" ;
167+ default :
168+ return "primary" ;
169+ }
170+ } ;
171+
172+ public getOrderStatusIconName = ( status : string ) : string => {
173+ switch ( status ) {
174+ case OrderStatus . PACKED :
175+ return "dropbox" ;
176+ case OrderStatus . IN_TRANSIT :
177+ return "delivery" ;
178+ case OrderStatus . CUSTOMS :
179+ return "bill-paid" ;
180+ case OrderStatus . DELIVERED :
181+ return "check" ;
182+ default :
183+ return "dropbox" ;
184+ }
185+ } ;
186+
161187 public formatDate ( value : string ) : string {
162188 return value || 'N/A' ;
163189 }
@@ -179,13 +205,18 @@ export class ErpHGridSampleComponent implements OnInit, AfterViewInit {
179205 public exportStarted ( args : IgxExporterEvent ) : void {
180206 args . exporter . columnExporting . subscribe ( ( columnArgs : IColumnExportingEventArgs ) => {
181207 // Don't export Performance column
182- columnArgs . cancel = columnArgs . header === 'Performance ' ;
208+ columnArgs . cancel = columnArgs . field === 'salesTrendData ' ;
183209 } ) ;
184210 }
185211
186- public onImageHover ( event : MouseEvent , dialog : IgxDialogComponent ) {
212+ public onImageHover ( event : MouseEvent , productName : string , dialog : IgxDialogComponent ) {
187213 if ( dialog ) {
188214 const targetEl = event . target as HTMLElement ;
215+ const imageUrl = targetEl . getAttribute ( "src" ) || '' ;
216+
217+ // Set current hovered image properties
218+ this . hoveredImageUrl = imageUrl ;
219+ this . hoveredImageProductName = productName ;
189220
190221 const positionSettings : PositionSettings = {
191222 openAnimation : useAnimation ( fadeIn , {
0 commit comments