Skip to content

Commit 02075d9

Browse files
MKirovaMKirova
authored andcommitted
Merge branch 'dkamburov/pivot-pipes' of https://github.com/IgniteUI/igniteui-angular.git
2 parents 27b22cb + d9921e9 commit 02075d9

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.pipes.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ describe('Pivot pipes', () => {
4848
filters: null
4949
};
5050

51-
it('transforms flat data to pivot data', () => {
51+
fit('transforms flat data to pivot data', () => {
5252
const rowPipeResult = rowPipe.transform(data, pivotConfigHierarchy.rows, pivotConfigHierarchy.values);
5353
const columnPipeResult = columnPipe.transform(rowPipeResult, pivotConfigHierarchy.columns, pivotConfigHierarchy.values);
5454
expect(columnPipeResult).toEqual([
5555
{ field1: 'All', All: 2127, Bulgaria: 774, USA: 829, Uruguay: 524, level: 0, records: [
56-
{ field1: 'Clothing', Bulgaria: 774, USA: 296, Uruguay: 456, level: 1 },
57-
{ field1: 'Bikes', Uruguay: 68, level: 1 },
58-
{ field1: 'Accessories', USA: 293, level: 1 },
59-
{ field1: 'Components', USA: 240, level: 1 }
56+
{ field1: 'Clothing', All: 1526, Bulgaria: 774, USA: 296, Uruguay: 456, level: 1 },
57+
{ field1: 'Bikes', All: 68, Uruguay: 68, level: 1 },
58+
{ field1: 'Accessories', All: 293, USA: 293, level: 1 },
59+
{ field1: 'Components', All: 240, USA: 240, level: 1 }
6060
] },
6161
{ field1: 'Clothing', All: 1526, Bulgaria: 774, USA: 296, Uruguay: 456, level: 1 },
6262
{ field1: 'Bikes', All: 68, Uruguay: 68, level: 1 },

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.pipes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export class IgxPivotColumnPipe implements PipeTransform {
6565
delete hierarchy[pivotKeys.records]; /* remove the helper records of the actual records so that
6666
expand indicators can be rendered properly */
6767
}
68-
result.push({...hierarchy, ...flatCols});
68+
for (const property in flatCols) {
69+
if (flatCols.hasOwnProperty(property)) {
70+
hierarchy[property] = flatCols[property];
71+
}
72+
}
73+
result.push(hierarchy);
6974
}
7075
});
7176

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-util.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class PivotUtil {
6262
}
6363

6464
public static flattenHierarchy(hierarchies, rec, dims, pivotKeys, level = 0) {
65-
let flatData = [];
65+
const flatData = [];
6666
for (const dim of dims) {
6767
hierarchies.forEach((h, key) => {
6868
const field = (dim && dim.fieldName) ?? this.generateFieldValue(rec);
@@ -74,7 +74,9 @@ export class PivotUtil {
7474
flatData.push(obj);
7575
if (h[pivotKeys.children]) {
7676
obj[pivotKeys.records] = this.flattenHierarchy(h[pivotKeys.children], rec, dim.childLevels, pivotKeys, level + 1);
77-
flatData = [...flatData, ...obj[pivotKeys.records]];
77+
for (const record of obj[pivotKeys.records]) {
78+
flatData.push(record);
79+
}
7880
}
7981
});
8082
}
@@ -83,15 +85,18 @@ export class PivotUtil {
8385
}
8486

8587
public static flattenColumnHierarchy(hierarchies, values, pivotKeys) {
86-
let flatData = [];
88+
const flatData = [];
8789
hierarchies.forEach((h, key) => {
8890
const obj = {};
8991
for (const value of values) {
9092
obj[key] = h[pivotKeys.aggregations][value.member];
9193
obj[pivotKeys.records] = h[pivotKeys.records];
9294
flatData.push(obj);
9395
if (h[pivotKeys.children]) {
94-
flatData = [...flatData, ...this.flattenColumnHierarchy(h[pivotKeys.children], values, pivotKeys)];
96+
const records = this.flattenColumnHierarchy(h[pivotKeys.children], values, pivotKeys);
97+
for (const record of records) {
98+
flatData.push(record);
99+
}
95100
}
96101
}
97102
});

0 commit comments

Comments
 (0)