Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !945

Sort has_many fields

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/tymate/sort_has_many into master Jul 21, 2017
  • Overview 41
  • Commits 9
  • Pipelines 0
  • Changes 14

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.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/tymate/sort_has_many