This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 5485eb9  feat: Add controlGroups to formData (#9740)
5485eb9 is described below

commit 5485eb993c99fef2548e7d20fff5888aae882ff4
Author: Ville Brofeldt <33317356+ville...@users.noreply.github.com>
AuthorDate: Wed May 6 14:53:13 2020 +0300

    feat: Add controlGroups to formData (#9740)
---
 .../spec/javascripts/explore/controlUtils_spec.jsx            | 11 +++++++++++
 superset-frontend/src/explore/controlUtils.js                 |  7 ++++++-
 superset-frontend/src/explore/controls.jsx                    |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx 
b/superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
index 7aedf10..aaac681 100644
--- a/superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/controlUtils_spec.jsx
@@ -23,7 +23,9 @@ import { t } from '@superset-ui/translation';
 import {
   getControlConfig,
   getControlState,
+  getFormDataFromControls,
   applyMapStateToPropsToControl,
+  getAllControlsState,
 } from '../../../src/explore/controlUtils';
 import ColumnOption from '../../../src/components/ColumnOption';
 
@@ -107,6 +109,7 @@ describe('controlUtils', () => {
                   name: 'all_columns',
                   config: {
                     type: 'SelectControl',
+                    controlGroup: 'columns',
                     multi: true,
                     label: t('Columns'),
                     default: [],
@@ -246,4 +249,12 @@ describe('controlUtils', () => {
       expect(control.validationErrors).toEqual(['cannot be empty']);
     });
   });
+
+  describe('controlGroup', () => {
+    it('in formData', () => {
+      const controlsState = getAllControlsState('table', 'table', {}, {});
+      const formData = getFormDataFromControls(controlsState);
+      expect(formData.controlGroups).toEqual({ all_columns: 'columns' });
+    });
+  });
 });
diff --git a/superset-frontend/src/explore/controlUtils.js 
b/superset-frontend/src/explore/controlUtils.js
index f4506a8..0dd2090 100644
--- a/superset-frontend/src/explore/controlUtils.js
+++ b/superset-frontend/src/explore/controlUtils.js
@@ -22,8 +22,13 @@ import * as SECTIONS from './controlPanels/sections';
 
 export function getFormDataFromControls(controlsState) {
   const formData = {};
+  formData.controlGroups = {};
   Object.keys(controlsState).forEach(controlName => {
-    formData[controlName] = controlsState[controlName].value;
+    const control = controlsState[controlName];
+    formData[controlName] = control.value;
+    if (control.hasOwnProperty('controlGroup')) {
+      formData.controlGroups[controlName] = control.controlGroup;
+    }
   });
   return formData;
 }
diff --git a/superset-frontend/src/explore/controls.jsx 
b/superset-frontend/src/explore/controls.jsx
index bc2b1e0..744e537 100644
--- a/superset-frontend/src/explore/controls.jsx
+++ b/superset-frontend/src/explore/controls.jsx
@@ -125,6 +125,7 @@ const timeColumnOption = {
 
 const groupByControl = {
   type: 'SelectControl',
+  controlGroup: 'groupby',
   multi: true,
   freeForm: true,
   label: t('Group by'),
@@ -156,6 +157,7 @@ const groupByControl = {
 
 const metrics = {
   type: 'MetricsControl',
+  controlGroup: 'metrics',
   multi: true,
   label: t('Metrics'),
   validators: [validateNonEmpty],

Reply via email to