@@ -252,10 +252,7 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
252
252
*/
253
253
public rowRemoved ( event : IBaseChipEventArgs ) {
254
254
const row = this . grid . pivotConfiguration . rows . find ( x => x . memberName === event . owner . id ) ;
255
- row . enabled = false ;
256
- this . grid . pipeTrigger ++ ;
257
- this . grid . filteringService . clearFilter ( row . memberName ) ;
258
- this . grid . dimensionsChange . emit ( { dimensions : this . grid . pivotConfiguration . rows , dimensionCollectionType : PivotDimensionType . Row } ) ;
255
+ this . grid . toggleDimension ( row ) ;
259
256
}
260
257
261
258
/**
@@ -264,12 +261,7 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
264
261
*/
265
262
public columnRemoved ( event : IBaseChipEventArgs ) {
266
263
const col = this . grid . pivotConfiguration . columns . find ( x => x . memberName === event . owner . id ) ;
267
- col . enabled = false ;
268
- this . grid . setupColumns ( ) ;
269
- this . grid . filteringService . clearFilter ( col . memberName ) ;
270
- this . grid . pipeTrigger ++ ;
271
- this . grid . dimensionsChange . emit ( { dimensions : this . grid . pivotConfiguration . columns , dimensionCollectionType : PivotDimensionType . Row } ) ;
272
- this . grid . reflow ( ) ;
264
+ this . grid . toggleDimension ( col ) ;
273
265
}
274
266
275
267
/**
@@ -290,10 +282,7 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
290
282
*/
291
283
public filterRemoved ( event : IBaseChipEventArgs ) {
292
284
const filter = this . grid . pivotConfiguration . filters . find ( x => x . memberName === event . owner . id ) ;
293
- filter . enabled = false ;
294
- this . grid . filteringService . clearFilter ( filter . memberName ) ;
295
- this . grid . pipeTrigger ++ ;
296
- this . grid . dimensionsChange . emit ( { dimensions : this . grid . pivotConfiguration . filters , dimensionCollectionType : PivotDimensionType . Filter } ) ;
285
+ this . grid . toggleDimension ( filter ) ;
297
286
}
298
287
299
288
/**
@@ -459,9 +448,9 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
459
448
* @hidden
460
449
* @internal
461
450
*/
462
- public onDimDrop ( event , area , dimension : PivotDimensionType ) {
451
+ public onDimDrop ( event , area , dimensionType : PivotDimensionType ) {
463
452
const dragId = event . dragChip ?. id || event . dragData ?. chip . id ;
464
- const currentDim = this . getDimensionsByType ( dimension ) ;
453
+ const currentDim = this . grid . getDimensionsByType ( dimensionType ) ;
465
454
const chipsArray = area . chipsList . toArray ( ) ;
466
455
const chip = chipsArray . find ( x => x . id === dragId ) ;
467
456
const isNewChip = chip === undefined ;
@@ -480,60 +469,18 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
480
469
// you have dragged something that is not a dimension
481
470
return ;
482
471
}
483
- const dimType = this . getDimensionsType ( dim ) ;
484
-
485
- // Dragged chip from a different dimension to the current one.
486
- const prevDimensionCollection = this . getDimensionsByType ( dimType ) ;
487
- // delete from previous dimension collection and add to current.
488
- prevDimensionCollection . splice ( prevDimensionCollection . indexOf ( dim ) , 1 ) ;
489
- currentDim . splice ( targetIndex , 0 , dim ) ;
490
-
491
- const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dragId ) ;
492
- if ( isDraggedFromColumn ) {
493
- // columns have changed.
494
- this . grid . setupColumns ( ) ;
495
- }
472
+ this . grid . moveDimension ( dim , dimensionType , targetIndex ) ;
496
473
} else if ( isReorder ) {
497
474
// chip from same collection, reordered.
498
475
const newDim = currentDim . find ( x => x . memberName === dragId ) ;
499
- //const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
500
476
const dragChipIndex = currentDim . findIndex ( x => x . memberName === dragId ) ;
501
- currentDim . splice ( dragChipIndex , 1 ) ;
502
- currentDim . splice ( dragChipIndex > chipIndex ? targetIndex : targetIndex - 1 , 0 , newDim ) ;
503
- }
504
- if ( dimension === PivotDimensionType . Column ) {
505
- // if columns have changed need to regenerate columns.
506
- this . grid . setupColumns ( ) ;
477
+ this . grid . moveDimension ( newDim , dimensionType , dragChipIndex > chipIndex ? targetIndex : targetIndex - 1 ) ;
507
478
}
508
- this . grid . pipeTrigger ++ ;
509
- this . grid . dimensionsChange . emit ( { dimensions : currentDim , dimensionCollectionType : dimension } ) ;
510
479
// clean states
511
480
this . onDimDragEnd ( ) ;
512
481
this . onAreaDragLeave ( event , area ) ;
513
482
}
514
483
515
- protected getDimensionsByType ( dimension : PivotDimensionType ) {
516
- switch ( dimension ) {
517
- case PivotDimensionType . Row :
518
- if ( ! this . grid . pivotConfiguration . rows ) {
519
- this . grid . pivotConfiguration . rows = [ ] ;
520
- }
521
- return this . grid . pivotConfiguration . rows ;
522
- case PivotDimensionType . Column :
523
- if ( ! this . grid . pivotConfiguration . columns ) {
524
- this . grid . pivotConfiguration . columns = [ ] ;
525
- }
526
- return this . grid . pivotConfiguration . columns ;
527
- case PivotDimensionType . Filter :
528
- if ( ! this . grid . pivotConfiguration . filters ) {
529
- this . grid . pivotConfiguration . filters = [ ] ;
530
- }
531
- return this . grid . pivotConfiguration . filters ;
532
- default :
533
- return null ;
534
- }
535
- }
536
-
537
484
protected getDimensionsType ( dimension : IPivotDimension ) {
538
485
const isColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dimension . memberName ) ;
539
486
const isRow = ! ! this . grid . pivotConfiguration . rows ?. find ( x => x && x . memberName === dimension . memberName ) ;
0 commit comments