Skip to content

Commit

Permalink
deep cloning column headers before operating on value to add aggregat…
Browse files Browse the repository at this point in the history
…ion column
  • Loading branch information
pat310 committed Nov 22, 2017
1 parent a8b67fe commit 67df225
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,15 @@ export function tableCreator(data, rows = [], cols = [], accCatOrCB,
type: 'aggregated',
};

const table = formattedColumnHeaders.concat(dataRows, accumulatedRows)
// TODO: fix this horrible hack of deep cloning object
const colHeadersCopy = JSON.parse(JSON.stringify(formattedColumnHeaders));

let counter = 0;
const table = colHeadersCopy.concat(dataRows, accumulatedRows)
.map((tableRow, i) => {
if (tableRow.type === 'data') {
tableRow.value = tableRow.value.concat(columnAggregations.splice(0, 1)[0]);
tableRow.value = tableRow.value.concat(columnAggregations[counter]);
counter += 1;
} else {
tableRow.value = tableRow.value.concat(i === 0 ? 'aggregated' : '');
}
Expand Down

0 comments on commit 67df225

Please sign in to comment.