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

Introduce an onInit method for when a new viz_type is selected #4491

Merged
merged 2 commits into from
Feb 28, 2018

Conversation

mistercrunch
Copy link
Member

This allows for clearing certain controls where/when needed. For
instance here, when loading deck_scatter, even if there was a time
granularity picked for the previous viz_type, we want to unselect it.

This allows for clearing certain controls where/when needed. For
instance here, when loading deck_scatter, even if there was a time
granularity picked for the previous viz_type, we want to unselect it.
@@ -81,6 +81,9 @@ export function getControlsState(state, form_data) {
control.value = formData[k] !== undefined ? formData[k] : control.default;
controlsState[k] = control;
});
if (viz.onInit) {
viz.onInit(controlsState);
Copy link
Member

@hughhhh hughhhh Feb 28, 2018

Choose a reason for hiding this comment

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

shouldn't we just return viz.onInit(controlState) Then in the function we can just return a new object. For example in visType.js we could now do this.

onInit: (controlState) => {
    return {
      ...controlState
      time_grain_sqla: {
          value: null
      }
      granularity: {
          value: null
      }
   }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

gets a bit more verbose I think:

onInit: (controlState) => {
    return {
      ...controlState
      time_grain_sqla: {
          ...controlState.time_grain_sqla,
          value: null,
      }
      granularity: {
          ...controlState.granularity,
          value: null,
      }
   }
}

it's clearly more functional / immutable, let me change it

@mistercrunch
Copy link
Member Author

@hughhhh addressed your comment, merging so I can package an internal release

@mistercrunch mistercrunch merged commit 264822b into apache:master Feb 28, 2018
@mistercrunch mistercrunch deleted the init_viztype branch February 28, 2018 06:36
mistercrunch added a commit to lyft/incubator-superset that referenced this pull request Feb 28, 2018
…e#4491)

* Introduce an onInit method for when a new viz_type is selected

This allows for clearing certain controls where/when needed. For
instance here, when loading deck_scatter, even if there was a time
granularity picked for the previous viz_type, we want to unselect it.

* making it functional

(cherry picked from commit 264822b)
hughhhh pushed a commit to lyft/incubator-superset that referenced this pull request Apr 1, 2018
* c2b42c4 - Change limit form 50k to 10k apache#4496
* 2932585 - [geo] add controls for minRadiusPixels and maxRadiusPixels in deck_scatter apache#4467
* 264822b - Introduce an onInit method for when a new viz_type is selected apache#4491
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
…e#4491)

* Introduce an onInit method for when a new viz_type is selected

This allows for clearing certain controls where/when needed. For
instance here, when loading deck_scatter, even if there was a time
granularity picked for the previous viz_type, we want to unselect it.

* making it functional
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
…e#4491)

* Introduce an onInit method for when a new viz_type is selected

This allows for clearing certain controls where/when needed. For
instance here, when loading deck_scatter, even if there was a time
granularity picked for the previous viz_type, we want to unselect it.

* making it functional
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.24.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.24.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants