Skip to content

Commit bc34778

Browse files
MKirovaMKirova
authored andcommitted
Additional small fixes.
1 parent 0e0ccb7 commit bc34778

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
5656
}
5757

5858
public onDimDragEnter(event, dimension: PivotDimensionType) {
59-
const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id) : null;
59+
const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id) :
60+
!this.grid.pivotConfiguration.values.find(x => x.member === event.dragChip.id);
6061
if (typeMismatch) {
6162
// cannot drag between dimensions and value
6263
return;
@@ -69,7 +70,8 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6970

7071
public onAreaDragEnter(event, area, dimension: PivotDimensionType) {
7172
const dragId = event.detail.owner.element.nativeElement.parentElement.id;
72-
const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === dragId) : null;
73+
const typeMismatch = dimension !== undefined ? this.grid.pivotConfiguration.values.find(x => x.member === dragId) :
74+
!this.grid.pivotConfiguration.values.find(x => x.member === dragId);
7375
if (typeMismatch) {
7476
// cannot drag between dimensions and value
7577
return;
@@ -94,11 +96,12 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
9496
const chipsArray = area.chipsList.toArray();
9597
const chipIndex = chipsArray.indexOf(event.owner) !== -1 ? chipsArray.indexOf(event.owner) : chipsArray.length;
9698
const newDim = currentDim.find(x => x.member === dragId);
97-
const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
98-
currentDim.splice(dragChipIndex, 1);
99-
currentDim.splice(dragChipIndex > chipIndex ? chipIndex : chipIndex - 1, 0, newDim);
100-
101-
this.grid.setupColumns();
99+
if (newDim) {
100+
const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
101+
currentDim.splice(dragChipIndex, 1);
102+
currentDim.splice(dragChipIndex > chipIndex ? chipIndex : chipIndex - 1, 0, newDim);
103+
this.grid.setupColumns();
104+
}
102105
}
103106

104107
public onDimDrop(event, area, dimension: PivotDimensionType) {
@@ -123,14 +126,18 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
123126
const newDim = Object.assign({}, dim);
124127
newDim.enabled = true;
125128
currentDim.splice(chipIndex, 0, newDim);
126-
this.grid.setupColumns();
129+
127130
} else {
128131
// chip from same collection, reordered.
129132
const newDim = currentDim.find(x => x.fieldName === dragId);
130133
const dragChipIndex = chipsArray.indexOf(event.dragChip || event.dragData.chip);
131134
currentDim.splice(dragChipIndex, 1);
132135
currentDim.splice(dragChipIndex > chipIndex ? chipIndex : chipIndex - 1, 0, newDim);
133136
}
137+
if (dimension === PivotDimensionType.Column) {
138+
// if columns have changed need to regenerate columns.
139+
this.grid.setupColumns();
140+
}
134141
this.grid.pipeTrigger++;
135142
}
136143
}

0 commit comments

Comments
 (0)