mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
Introduce an onInit method for when a new viz_type is selected (#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 commit is contained in:
committed by
GitHub
parent
404e2d552a
commit
264822b1ee
@@ -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) {
|
||||
return viz.onInit(controlsState);
|
||||
}
|
||||
return controlsState;
|
||||
}
|
||||
|
||||
|
||||
@@ -627,6 +627,17 @@ export const visTypes = {
|
||||
deck_scatter: {
|
||||
label: t('Deck.gl - Scatter plot'),
|
||||
requiresTime: true,
|
||||
onInit: controlState => ({
|
||||
...controlState,
|
||||
time_grain_sqla: {
|
||||
...controlState.time_grain_sqla,
|
||||
value: null,
|
||||
},
|
||||
granularity: {
|
||||
...controlState.granularity,
|
||||
value: null,
|
||||
},
|
||||
}),
|
||||
controlPanelSections: [
|
||||
{
|
||||
label: t('Query'),
|
||||
|
||||
Reference in New Issue
Block a user