Created by: pauldub
Hi!
I'm opening this pull request to disscuss how sorting has_many
dashboard fields could be implemented. This is the implementation we are using but it could be done better.
I'm copying the text from the issue I opened with comments regarding improvements:
It is currently not possible to sort an HasMany field on the model's show view such as http://administrate-prototype.herokuapp.com/admin/customers/9085?direction=asc&order=address_state. There was a similar issue with its pagination which was fixed with release 0.5.0.
I have implemented it on a fork but I think it would require a bit more work. My implementation is based on the work done in PR #736
I suggest that we use a convention of #{attr_name}[param], for example orders[page] for the pagination and orders[direction] & orders[order] for sorting. But the issue is that there is currently no proper way to do this except by adding more arguments to the Page::Collection methods. Maybe a better solution would be to be able to propagate request parameters through Page#attribute_field overriding options for the field. It would be consistent with the HasMany field implementation and its pagination could be implemented that way too (having page as an option).
What are your thoughts about this? I am willing to push this (small) feature as it is a great quality of life improvement and follows the extensibility goals set by the project.