Skip to content

Commit

Permalink
Merge 3cf84c8 into b19de9c
Browse files Browse the repository at this point in the history
  • Loading branch information
turnerniles committed Mar 10, 2017
2 parents b19de9c + 3cf84c8 commit 2c4ea82
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/quick-pivot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/quick-pivot.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/quick-pivot.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/quick-pivot.min.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export default class Pivot {
return this;
}

toggle(rowNum) {
if (rowNum in this.collapsedRows) {
return this.expand(rowNum);
}
return this.collapse(rowNum);
}

getData(rowNum) {
if (!this.data.table[rowNum]) return null;
if (this.collapsedRows[this.data.table[rowNum].row]) {
Expand Down
16 changes: 16 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ describe('pivot', () => {
expect(pivot.getData(1)).to.deep.equal(uncollapsedData);
});

it('should return table to normal state when toggled twice', () => {
const pivot = new Pivot(
dataArray,
rowsToPivot,
colsToPivot,
aggregationCategory,
aggregationType,
);

const startState = pivot.data.table;

pivot.toggle(1).toggle(1);

expect(startState).to.deep.equal(pivot.data.table);
});

it('should expand correct rows', () => {
const pivot = new Pivot(
dataArray,
Expand Down

0 comments on commit 2c4ea82

Please sign in to comment.