Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to the react-pivottable component #79

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"test:jest": "jest",
"test": "npm run test:eslint && npm run test:prettier && npm run test:jest",
"clean": "rm -rf __tests__ PivotTable.js* PivotTableUI.js* PlotlyRenderers.js* TableRenderers.js* Utilities.js* pivottable.css",
"doPublish": "npm run clean && cp src/pivottable.css . && babel src --out-dir=. --source-maps --presets=env,react --plugins babel-plugin-add-module-exports && npm publish",
"build": "npm run clean && cp src/pivottable.css . && babel src --out-dir=. --source-maps --presets=env,react --plugins babel-plugin-add-module-exports",
"prepare": "npm run build",
"doPublish": "npm run build && npm publish",
"postpublish": "npm run clean",
"deploy": "webpack -p && mv bundle.js examples && cd examples && git init && git add . && git commit -m build && git push --force [email protected]:plotly/react-pivottable.git master:gh-pages && rm -rf .git bundle.js"
},
Expand Down
89 changes: 45 additions & 44 deletions src/PivotTableUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class DraggableAttribute extends React.Component {
style={{
display: 'block',
cursor: 'initial',
zIndex: this.props.zIndex
zIndex: this.props.zIndex,
}}
onClick={() => this.props.moveFilterBoxToTop(this.props.name)}
>
Expand Down Expand Up @@ -135,7 +135,7 @@ export class DraggableAttribute extends React.Component {
}

toggleFilterBox() {
this.setState({ open: !this.state.open});
this.setState({open: !this.state.open});
this.props.moveFilterBoxToTop(this.props.name);
}

Expand Down Expand Up @@ -367,19 +367,15 @@ 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 +388,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 +408,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 +467,9 @@ class PivotTableUI extends React.PureComponent {
])}
</td>
);
}

render() {
const unusedAttrs = Object.keys(this.attrValues)
.filter(
e =>
Expand Down Expand Up @@ -520,40 +523,38 @@ 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>
);
}

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

return (
<table className="pvtUi">
<tbody onClick={() => this.setState({openDropdown: false})}>
{outputRows}
</tbody>
</table>
);
Expand Down
Loading