Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Implement Column Sorting and Actions #537

Merged
merged 1 commit into from
May 23, 2018
Merged

Conversation

pzuraq
Copy link
Contributor

@pzuraq pzuraq commented May 23, 2018

This PR implements column sorting with a default sort implementation,
and dropdown actions, which can be passed in at the header cell level.
Dropdown actions can be used to add buttons to the dropdown menu
associated with each column.

The sorting functionality is accomplished via merge sorting each level
of the CollapseTree. This also leaves the default sort intact, so users
can return to the default state.

Dropdown actions have been tested and documented, but the docs are not
exposed via navigation yet. Unsure of the API at this point.

Styles to come in the next PR.

This PR implements column sorting with a default sort implementation,
and dropdown actions, which can be passed in at the header cell level.
Dropdown actions can be used to add buttons to the dropdown menu
associated with each column.

The sorting functionality is accomplished via merge sorting each level
of the CollapseTree. This also leaves the default sort intact, so users
can return to the default state.

Dropdown actions have been tested and documented, but the docs are not
exposed via navigation yet. Unsure of the API at this point.

Styles to come in the next PR.
@pzuraq pzuraq force-pushed the pzuraq/feature/sortings branch from af188ff to a798100 Compare May 23, 2018 19:35
@pzuraq pzuraq merged commit a583ea7 into master May 23, 2018
@pzuraq pzuraq deleted the pzuraq/feature/sortings branch May 23, 2018 20:36
@addepar-andy
Copy link
Contributor

don't super understand the api here. how would i turn off built in sorting?

@pzuraq
Copy link
Contributor Author

pzuraq commented Jun 13, 2018

It depends on what you mean by "turn off". So far we're using a DDAU philosophy for modifying external data where possible (this isn't really possible with e.g. columns yet, because the data structure is so complicated).

So, when you click on a table header cell, it sends the new sort order up in an action. It doesn't change any sort ordering itself yet, and if you don't set the new sorts in the parent context, it will not update. The external context retains control.

Taking it one step backward, if there is no onUpdateSorts action, there is nothing to do when users click on the header. So, we only apply the sort actions and styles to header cell IF there is an onUpdateSorts action, and omitting it will "disable" sorting.

However, if you were to pass down sorts to the table, it would still actually sort! So you can disable user interaction, without disabling sorting itself.

If that seems confusing, consider this: You've been asked to create a sort dropdown external to the table, that changes the sort columns. This is supposed to replace the standard table interaction we included with the table, so you don't want to disable sorting, just provide a different (external) UX.

This API gives us that flexibility and makes the table component that much easier to use in different scenarios.

@addepar-andy
Copy link
Contributor

cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants