You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/02/28 06:36:54 UTC

[GitHub] mistercrunch closed pull request #4491: Introduce an onInit method for when a new viz_type is selected

mistercrunch closed pull request #4491: Introduce an onInit method for when a new viz_type is selected
URL: https://github.com/apache/incubator-superset/pull/4491
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/javascripts/explore/stores/store.js b/superset/assets/javascripts/explore/stores/store.js
index af809ed2fa..02bd121e65 100644
--- a/superset/assets/javascripts/explore/stores/store.js
+++ b/superset/assets/javascripts/explore/stores/store.js
@@ -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;
 }
 
diff --git a/superset/assets/javascripts/explore/stores/visTypes.js b/superset/assets/javascripts/explore/stores/visTypes.js
index e81e7b815f..a41b81b339 100644
--- a/superset/assets/javascripts/explore/stores/visTypes.js
+++ b/superset/assets/javascripts/explore/stores/visTypes.js
@@ -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'),


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services