You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/12 15:46:24 UTC

[GitHub] [superset] geido commented on a change in pull request #18009: feat: log scale and step size control for range filters [WIP]

geido commented on a change in pull request #18009:
URL: https://github.com/apache/superset/pull/18009#discussion_r783185579



##########
File path: superset-frontend/src/filters/components/Range/controlPanel.ts
##########
@@ -69,6 +69,41 @@ const config: ControlPanelConfig = {
             },
           },
         ],
+        [
+          {
+            name: 'logScale',
+            config: {
+              type: 'CheckboxControl',
+              label: t('Logarithmic Scale'),

Review comment:
       ```suggestion
                 label: t('Logarithmic scale'),
   ```

##########
File path: superset-frontend/src/filters/components/Range/controlPanel.ts
##########
@@ -69,6 +69,41 @@ const config: ControlPanelConfig = {
             },
           },
         ],
+        [
+          {
+            name: 'logScale',
+            config: {
+              type: 'CheckboxControl',
+              label: t('Logarithmic Scale'),
+              default: false,
+              renderTrigger: true,
+              description: t('Make the scale logarithmic.'),
+            },
+          },
+        ],
+        [
+          {
+            name: 'stepSize',
+            config: {
+              type: 'SelectControl',
+              label: t('Step Size'),

Review comment:
       ```suggestion
                 label: t('Step size'),
   ```

##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
##########
@@ -211,6 +213,69 @@ export default function getControlItemsMap({
       );
       mapControlItems[controlItem.name] = { element, checked: initialValue };
     });
+  controlItems
+    .filter(
+      (controlItem: CustomControlItem) =>
+        controlItem?.config?.renderTrigger &&
+        controlItem.name !== 'sortAscending' &&
+        controlItem?.config?.type === 'SelectControl',
+    )
+    .forEach(controlItem => {
+      const initialValue =
+        filterToEdit?.controlValues?.[controlItem.name] ??
+        controlItem?.config?.default;
+      const element = (
+        <>
+          <CleanFormItem
+            name={['filters', filterId, 'requiredFirst', controlItem.name]}
+            hidden
+            initialValue={
+              controlItem?.config?.requiredFirst && filterToEdit?.requiredFirst
+            }
+          />
+          <Tooltip
+            key={controlItem.name}
+            placement="left"
+            title={
+              controlItem.config.affectsDataMask &&
+              disabled &&
+              t('Populate "Default value" to enable this control')
+            }
+          >
+            <StyledRowFormItem
+              key={controlItem.name}
+              name={['filters', filterId, 'controlValues', controlItem.name]}
+              initialValue={initialValue}
+              valuePropName="option"
+              colon={false}
+              label={
+                <StyledLabel>
+                  {t(`${controlItem.config?.label}`) || t('Select')}
+                </StyledLabel>
+              }
+            >
+              <SelectControl
+                name={controlItem.name}
+                clearable={false}
+                freeForm={controlItem.config.freeForm}
+                disabled={controlItem.config.affectsDataMask && disabled}
+                onChange={(value: any) => {
+                  setNativeFilterFieldValues(form, filterId, {
+                    [controlItem.name]: value,
+                    defaultDataMask: null,
+                  });
+                  // controlItem.config.value = value;

Review comment:
       ```suggestion
   ```

##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx
##########
@@ -211,6 +213,69 @@ export default function getControlItemsMap({
       );
       mapControlItems[controlItem.name] = { element, checked: initialValue };
     });
+  controlItems
+    .filter(
+      (controlItem: CustomControlItem) =>
+        controlItem?.config?.renderTrigger &&
+        controlItem.name !== 'sortAscending' &&
+        controlItem?.config?.type === 'SelectControl',
+    )
+    .forEach(controlItem => {
+      const initialValue =
+        filterToEdit?.controlValues?.[controlItem.name] ??
+        controlItem?.config?.default;
+      const element = (
+        <>
+          <CleanFormItem
+            name={['filters', filterId, 'requiredFirst', controlItem.name]}
+            hidden
+            initialValue={
+              controlItem?.config?.requiredFirst && filterToEdit?.requiredFirst
+            }
+          />
+          <Tooltip
+            key={controlItem.name}
+            placement="left"
+            title={
+              controlItem.config.affectsDataMask &&
+              disabled &&
+              t('Populate "Default value" to enable this control')
+            }
+          >
+            <StyledRowFormItem
+              key={controlItem.name}
+              name={['filters', filterId, 'controlValues', controlItem.name]}
+              initialValue={initialValue}
+              valuePropName="option"
+              colon={false}
+              label={
+                <StyledLabel>
+                  {t(`${controlItem.config?.label}`) || t('Select')}
+                </StyledLabel>
+              }
+            >
+              <SelectControl
+                name={controlItem.name}
+                clearable={false}
+                freeForm={controlItem.config.freeForm}
+                disabled={controlItem.config.affectsDataMask && disabled}
+                onChange={(value: any) => {

Review comment:
       Do you think we can be more specific for the type of the `value` of this `onChange` event?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org