@@ -67,6 +67,11 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6767 this . grid . pipeTrigger ++ ;
6868 }
6969
70+ public filterRemoved ( event : IBaseChipEventArgs ) {
71+ const filter = this . grid . pivotConfiguration . filters . find ( x => x . fieldName === event . owner . id ) ;
72+ filter . enabled = false ;
73+ }
74+
7075 public onDimDragEnter ( event , dimension : PivotDimensionType ) {
7176 const typeMismatch = dimension !== undefined ? this . grid . pivotConfiguration . values . find ( x => x . member === event . dragChip . id ) :
7277 ! this . grid . pivotConfiguration . values . find ( x => x . member === event . dragChip . id ) ;
@@ -91,13 +96,15 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
9196 // cannot drag between dimensions and value
9297 return ;
9398 }
94- const lastElem = area . chipsList . last . nativeElement ;
95- const targetElem = event . detail . originalEvent . target ;
96- const targetOwner = event . detail . owner . element . nativeElement . parentElement ;
97- if ( targetOwner !== lastElem && targetElem . getBoundingClientRect ( ) . x >= lastElem . getBoundingClientRect ( ) . x ) {
98- this . renderer . addClass ( area . chipsList . last . nativeElement , this . _dropIndicatorClass ) ;
99- // TODO- remove once classes are added.
100- area . chipsList . last . nativeElement . style . borderRight = '1px solid red' ;
99+ const lastElem = area . chipsList . last ?. nativeElement ;
100+ if ( lastElem ) {
101+ const targetElem = event . detail . originalEvent . target ;
102+ const targetOwner = event . detail . owner . element . nativeElement . parentElement ;
103+ if ( targetOwner !== lastElem && targetElem . getBoundingClientRect ( ) . x >= lastElem . getBoundingClientRect ( ) . x ) {
104+ this . renderer . addClass ( area . chipsList . last . nativeElement , this . _dropIndicatorClass ) ;
105+ // TODO- remove once classes are added.
106+ area . chipsList . last . nativeElement . style . borderRight = '1px solid red' ;
107+ }
101108 }
102109 }
103110 public onAreaDragLeave ( event , area ) {
@@ -124,24 +131,25 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
124131
125132 public onDimDrop ( event , area , dimension : PivotDimensionType ) {
126133 const dragId = event . dragChip ?. id || event . dragData ?. chip . id ;
127- const currentDim = dimension === PivotDimensionType . Row ? this . grid . pivotConfiguration . rows :
128- this . grid . pivotConfiguration . columns ;
134+ const currentDim = this . getDimensionsByType ( dimension ) ;
129135 const chipsArray = area . chipsList . toArray ( ) ;
130136 const chip = chipsArray . find ( x => x . id === dragId ) ;
131137 const isNewChip = chip === undefined ;
132138 const chipIndex = chipsArray . indexOf ( event . owner ) !== - 1 ? chipsArray . indexOf ( event . owner ) : chipsArray . length ;
133139 if ( isNewChip ) {
140+ const allDims = this . grid . pivotConfiguration . rows
141+ . concat ( this . grid . pivotConfiguration . columns )
142+ . concat ( this . grid . pivotConfiguration . filters ) ;
134143 // chip moved from external collection
135- const oppositeDim = dimension === PivotDimensionType . Row ? this . grid . pivotConfiguration . columns :
136- this . grid . pivotConfiguration . rows ;
137- const dim = oppositeDim . find ( x => x . fieldName === dragId ) ;
144+ const dim = allDims . find ( x => x && x . fieldName === dragId ) ;
138145 if ( ! dim ) {
139146 // you have dragged something that is not a dimension
140147 return ;
141148 }
142149 dim . enabled = false ;
143- if ( dimension === PivotDimensionType . Row ) {
144- // opposite dimension has changed.
150+ const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . fieldName === dragId ) ;
151+ if ( isDraggedFromColumn ) {
152+ // columns have changed.
145153 this . grid . setupColumns ( ) ;
146154 }
147155
@@ -162,4 +170,26 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
162170 }
163171 this . grid . pipeTrigger ++ ;
164172 }
173+
174+ protected getDimensionsByType ( dimension : PivotDimensionType ) {
175+ switch ( dimension ) {
176+ case PivotDimensionType . Row :
177+ if ( ! this . grid . pivotConfiguration . rows ) {
178+ this . grid . pivotConfiguration . rows = [ ] ;
179+ }
180+ return this . grid . pivotConfiguration . rows ;
181+ case PivotDimensionType . Column :
182+ if ( ! this . grid . pivotConfiguration . columns ) {
183+ this . grid . pivotConfiguration . columns = [ ] ;
184+ }
185+ return this . grid . pivotConfiguration . columns ;
186+ case PivotDimensionType . Filter :
187+ if ( ! this . grid . pivotConfiguration . filters ) {
188+ this . grid . pivotConfiguration . filters = [ ] ;
189+ }
190+ return this . grid . pivotConfiguration . filters ;
191+ default :
192+ return null ;
193+ }
194+ }
165195}
0 commit comments