ktmud commented on a change in pull request #19381:
URL: https://github.com/apache/superset/pull/19381#discussion_r838144990



##########
File path: 
superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx
##########
@@ -66,6 +66,7 @@ function loadData(
     alignPn = false,
     showCellBars = true,
     includeSearch = true,
+    rearrangeColumns = false,

Review comment:
       ```suggestion
       allowRearrangeColumns = false,
   ```
   
   Let's make variable names more explicit.

##########
File path: 
superset-frontend/packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-table/TableStories.tsx
##########
@@ -117,15 +119,17 @@ export const BigTable = ({ width, height }) => {
   const cols = number('Columns', 8, { range: true, min: 1, max: 20 });
   const pageLength = number('Page size', 50, { range: true, min: 0, max: 100 
});
   const includeSearch = boolean('Include search', true);
-  const alignPn = boolean('Algin PosNeg', false);
+  const alignPn = boolean('Align PosNeg', false);

Review comment:
       💯 

##########
File path: superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx
##########
@@ -445,6 +445,20 @@ const config: ControlPanelConfig = {
             },
           },
         ],
+        [
+          {
+            name: 'rearrange_columns',
+            config: {
+              type: 'CheckboxControl',
+              label: t('Allow columns to be rearranged'),
+              renderTrigger: true,
+              default: false,
+              description: t(
+                'Allow the end user to drag-and-drop the column headers to 
rearrange them.',

Review comment:
       ```suggestion
                   "Allow end user to drag-and-drop column headers to rearrange 
them. Note their changes won't persist for the next time they open the chart.",
   ```

##########
File path: 
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx
##########
@@ -210,6 +218,33 @@ export default function DataTable<D extends object>({
 
   const shouldRenderFooter = columns.some(x => !!x.Footer);
 
+  let columnBeingDragged = -1;
+
+  const onDragStart = (e: React.DragEvent) => {
+    const el = e.target as HTMLTableCellElement;
+    columnBeingDragged = allColumns.findIndex(
+      col => col.id === el.dataset.columnName,
+    );
+    e.dataTransfer.setData('text/plain', `${columnBeingDragged}`);

Review comment:
       I'm not familiar with react-table's DnD but is this dataTransfer 
required?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to