Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 25 additions & 42 deletions src/PivotTableUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,14 @@ class PivotTableUI extends React.PureComponent {
);
}

render() {
const numValsAllowed =
this.props.aggregators[this.props.aggregatorName]([])().numInputs || 0;

const rendererName =
this.props.rendererName in this.props.renderers
? this.props.rendererName
: Object.keys(this.props.renderers)[0];

const rendererCell = (
rendererCell() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the changes here just refactoring or are they required for the new renderer to function?

return (
<td className="pvtRenderers">
<Dropdown
current={rendererName}
current={this.props.rendererName in this.props.renderers
? this.props.rendererName
: Object.keys(this.props.renderers)[0]
}
values={Object.keys(this.props.renderers)}
open={this.isOpen('renderer')}
zIndex={this.isOpen('renderer') ? this.state.maxZIndex + 1 : 1}
Expand All @@ -392,6 +387,11 @@ class PivotTableUI extends React.PureComponent {
/>
</td>
);
}

aggregatorCell() {
const numValsAllowed =
this.props.aggregators[this.props.aggregatorName]([])().numInputs || 0;

const sortIcons = {
key_a_to_z: {
Expand All @@ -407,7 +407,7 @@ class PivotTableUI extends React.PureComponent {
value_z_to_a: {rowSymbol: '↑', colSymbol: '←', next: 'key_a_to_z'},
};

const aggregatorCell = (
return (
<td className="pvtVals">
<Dropdown
current={this.props.aggregatorName}
Expand Down Expand Up @@ -466,7 +466,9 @@ class PivotTableUI extends React.PureComponent {
])}
</td>
);
}

render() {
const unusedAttrs = Object.keys(this.attrValues)
.filter(
e =>
Expand Down Expand Up @@ -520,40 +522,21 @@ class PivotTableUI extends React.PureComponent {
</td>
);

if (horizUnused) {
return (
<table className="pvtUi">
<tbody onClick={() => this.setState({openDropdown: false})}>
<tr>
{rendererCell}
{unusedAttrsCell}
</tr>
<tr>
{aggregatorCell}
{colAttrsCell}
</tr>
<tr>
{rowAttrsCell}
{outputCell}
</tr>
</tbody>
</table>
);
}
const outputRows = horizUnused
? [
(<tr key="R">{this.rendererCell()}{unusedAttrsCell}</tr>),
(<tr key="A">{this.aggregatorCell()}{colAttrsCell}</tr>),
(<tr key="O">{rowAttrsCell}{outputCell}</tr>),
]
: [
(<tr key="RA">{this.rendererCell()}{this.aggregatorCell()}{colAttrsCell}</tr>),
(<tr key="O">{unusedAttrsCell}{rowAttrsCell}{outputCell}</tr>),
];

return (
<table className="pvtUi">
<tbody onClick={() => this.setState({openDropdown: false})}>
<tr>
{rendererCell}
{aggregatorCell}
{colAttrsCell}
</tr>
<tr>
{unusedAttrsCell}
{rowAttrsCell}
{outputCell}
</tr>
{outputRows}
</tbody>
</table>
);
Expand Down
Loading