-
Notifications
You must be signed in to change notification settings - Fork 272
feat: add drag and drop column rearrangement for table plugin #1423
feat: add drag and drop column rearrangement for table plugin #1423
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/superset/superset-ui/Erf3zM6ixAtL3GuyvxPXXhJPBmDu |
Codecov Report
@@ Coverage Diff @@
## master #1423 +/- ##
==========================================
- Coverage 30.91% 30.89% -0.03%
==========================================
Files 502 502
Lines 10220 10243 +23
Branches 1762 1765 +3
==========================================
+ Hits 3160 3165 +5
- Misses 6808 6825 +17
- Partials 252 253 +1
Continue to review full report at Codecov.
|
I think this is a great improvement @stevetracvc! To make these changes stick, however, it would be nice if we could add drag'n'drop support to the "Customize columns" control, which would persist the order. If we added that support, do you think that would be sufficient, or would it make sense to also support the temporary column rearrangement introduced in this PR? |
@villebro I don't think it's nearly as useful to the table designer, as there's already the drag-and-drop in the list of columns for reorganizing the columns on that page. This is intended to be used by the end users, so they can customize it to their liking. I only did the video on the explore page so you could see what happens after adding the check mark :) But if you think designers would want it too, that's another discussion. :) And since it's the end users doing the reordering, I didn't see any need to make the new ordering stick (at least globally, as someone could really screw with the rearrangement and ruin it for everyone). One possible addition I can see would be to make an individual user's reorganization something that's stored in the local session, so that coming back in the future, the columns would be in the same order. But that seems like it could get messy and we'd need to figure out how to make sure that it's the same: user, dashboard, table, among other things, to make sure there's no adverse affects. From my testing, applying new filters and even force refreshing the data does not reset the column order, it only resets when you browser refresh the dashboard. |
|
added a toggle val to keep track of whether the columns were rearranged. if so, then force getColumnConfigs to recalculate the widths
This is a great improvement! Thank you @stevetracvc It works similar to googlesheet and I don't think adding a control in the panel is necessary. but I do agree the changes should persist while the chart is added to dashboard. @villebro If the code looks ok and test is sufficient , I think we should merge it in and make incremental improvement later. |
@junlincc are you saying you think the column order should persist on a given end user's computer, even after closing the browser and coming back? I think that'd be nice, but I also think it'd be great for all the filters and such to be remembered too. From what I can tell, it appears that the general design of Superset is for it to start from scratch every time the dashboard is reloaded. Is there any infrastructure yet to make any user settings non-volatile? Stored for the user in the database? |
When toggling the dnd feature, it was adding or removing the useColumnOrder hook which changed the dimensions of the memoization array. Now, useColumnOrder is always enabled, but the column headers themselves aren't drag or drop targets when the feature is disabled.
I think @junlincc's comment is intending to state that if a chart author rearranges columns, and then hits Save, then that column order should be persisted with the chart and reflected on dashboards. I think the proper way to do this might be to have the drag and drop action also update the form data and update the order of the control values to match (dynamic controls, essentially). Then saving it would persist the form data that way, and all would be well. Dashboard consumers could still re-order columns as much as they'd like, without persisting the state there. |
@rusackas ok, but a few questions:
|
The codebase on this repo has been moved to the main Apache Superset repo, and consequently the repo is in the process of being archived. See the Superset Improvement Proposal for details: apache/superset#13013 . While all currently open issues and PRs will be closed, we encourage you to reopen this PR on the main repo, which should be as simple as moving over any code changes as follows:
If you need help with the migration, please post a message on the SIP or reach out on the community Slack. |
🏆 Enhancements
Add the ability for the end user to drag and drop columns for a table visualization
📜 Documentation
Table designer can enable column rearrangement in the config options when building the table. Then, user can drag columns around
These are volatile changes, so when the browser is refreshed, the column order goes back to default. Demo is in the chart edit page, which is just for simple demonstration purposes. This is intended for the end user to be allowed to rearrange the columns.
Not enabled
Enabled
closes #1420