@@ -67,34 +67,55 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6767 event . owner . nativeElement . style . borderLeft = '' ;
6868 }
6969
70+ public onAreaDragEnter ( event , area ) {
71+ const dragId = event . detail . owner . element . nativeElement . parentElement . id ;
72+ const isValue = this . grid . pivotConfiguration . values . find ( x => x . member === dragId ) ;
73+ if ( isValue ) {
74+ // cannot drag value in dimensions
75+ return ;
76+ }
77+ const lastElem = area . chipsList . last . nativeElement ;
78+ const targetElem = event . detail . originalEvent . target ;
79+ const targetOwner = event . detail . owner . element . nativeElement . parentElement ;
80+ if ( targetOwner !== lastElem && targetElem . getBoundingClientRect ( ) . x >= lastElem . getBoundingClientRect ( ) . x ) {
81+ area . chipsList . last . nativeElement . style . borderRight = '1px solid red' ;
82+ }
83+ }
84+ public onAreaDragLeave ( event , area ) {
85+ area . chipsList . toArray ( ) . forEach ( element => {
86+ element . nativeElement . style . borderRight = '' ;
87+ } ) ;
88+ }
89+
7090 public onDimDrop ( event , area , dimension : PivotDimensionType ) {
91+ const dragId = event . dragChip ?. id || event . dragData ?. chip . id ;
7192 const currentDim = dimension === PivotDimensionType . Row ? this . grid . pivotConfiguration . rows :
7293 this . grid . pivotConfiguration . columns ;
7394 const chipsArray = area . chipsList . toArray ( ) ;
74- const chip = chipsArray . find ( x => x . id === event . dragChip . id ) ;
95+ const chip = chipsArray . find ( x => x . id === dragId ) ;
7596 const isNewChip = chip === undefined ;
76- const currIndex = area . chipsList . toArray ( ) . indexOf ( event . owner ) ;
97+ const chipIndex = chipsArray . indexOf ( event . owner ) !== - 1 ? chipsArray . indexOf ( event . owner ) : chipsArray . length ;
7798 if ( isNewChip ) {
7899 // chip moved from external collection
79100 const oppositeDim = dimension === PivotDimensionType . Row ? this . grid . pivotConfiguration . columns :
80101 this . grid . pivotConfiguration . rows ;
81- const dim = oppositeDim . find ( x => x . fieldName === event . dragChip . id ) ;
82- if ( ! dim ) {
102+ const dim = oppositeDim . find ( x => x . fieldName === dragId ) ;
103+ if ( ! dim ) {
83104 // you have dragged something that is not a dimension
84105 return ;
85106 }
86107 dim . enabled = false ;
87108
88109 const newDim = Object . assign ( { } , dim ) ;
89110 newDim . enabled = true ;
90- currentDim . splice ( currIndex , 0 , newDim ) ;
111+ currentDim . splice ( chipIndex , 0 , newDim ) ;
91112 this . grid . setupColumns ( ) ;
92113 } else {
93114 // chip from same collection, reordered.
94- const newDim = currentDim . find ( x => x . fieldName === event . dragChip . id ) ;
95- const dragChipIndex = chipsArray . indexOf ( event . dragChip ) ;
115+ const newDim = currentDim . find ( x => x . fieldName === dragId ) ;
116+ const dragChipIndex = chipsArray . indexOf ( event . dragChip || event . dragData . chip ) ;
96117 currentDim . splice ( dragChipIndex , 1 ) ;
97- currentDim . splice ( currIndex , 0 , newDim ) ;
118+ currentDim . splice ( dragChipIndex > chipIndex ? chipIndex : chipIndex - 1 , 0 , newDim ) ;
98119 }
99120 this . grid . pipeTrigger ++ ;
100121 }
0 commit comments