-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
Conversation
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.
e1412ad
to
cc794c2
Compare
@@ -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); |
There was a problem hiding this comment.
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
}
}
}
There was a problem hiding this comment.
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
1791eb9
to
3e152f9
Compare
@hughhhh addressed your comment, merging so I can package an internal release |
…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)
* 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
…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
…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
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.