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

Expose aggregator outlet to allow rendering additional content in aggregatorCell #116

Merged
merged 3 commits into from
Nov 19, 2020

Conversation

nselikoff
Copy link
Contributor

@nselikoff nselikoff commented Oct 16, 2020

This PR introduces an additional key on aggregators, outlet, a function which, if present, gets called once by PivotTableUI to render additional aggregator-specific content just below the built-in aggregator selector (in the area outlined in red here):

Screen Shot 2020-10-19 at 11 50 34 AM

Some use cases for providing this escape hatch include:

  • rendering aggregator-specific custom UI controls
  • rendering aggregate stats that you want visible regardless of the state of the pivottable attributes

When the outlet function is called, it will be passed the PivotTableUI's props.data, in case the called aggregator wants to make use of that data.

Here's a kind of silly example of a custom aggregator using this new function:

  function customCount(formatter) {
    return () => 
      function() {
        return {
          count: 0,
          push() {
            this.count++;
          },
          value() {
            return this.count;
          },
          format: formatter,
          outlet: (records) => {
            return (
              <div>There are ${records.length} records total</div>
            );
          },
        };
      };
    };
  },

Resolves #117

@nselikoff nselikoff changed the title Expose aggregator controls Expose aggregator outlet Oct 19, 2020
@nselikoff nselikoff changed the title Expose aggregator outlet Expose aggregator outlet to allow rendering additional content in aggregatorCell Oct 19, 2020
@@ -25,7 +25,8 @@
"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",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split out the build from the doPublish so I could include my local branch of react-pivottable in another app to prototype the new feature.

@nselikoff nselikoff marked this pull request as ready for review October 19, 2020 16:14
@nicolaskruchten
Copy link
Member

Seems reasonable to me! I don't have time just now to test and release but I will do so within a couple of days. Please ping me again if I don't get to it?

@nselikoff
Copy link
Contributor Author

For sure, thanks!

@nselikoff
Copy link
Contributor Author

Hey @nicolaskruchten pinging you on this :)

@nicolaskruchten nicolaskruchten merged commit a16e8e2 into plotly:master Nov 19, 2020
@nicolaskruchten
Copy link
Member

Sorry for the delay... this is now out in v0.11.0.

If you want to keep working on this, maybe I can add you as a contributor and let you do releases?

@nselikoff nselikoff deleted the aggregator-controls branch January 21, 2021 19:20
@nselikoff
Copy link
Contributor Author

Thank you very much for this and apologies for the long delay in responding. Thanks for the contributor offer as well, but I need to pass for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose aggregator outlet to allow rendering additional content in aggregatorCell
2 participants