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
  • Issues
  • #2276
Closed
Open
Issue created Oct 05, 2022 by tancrede@tancrede

Manual sorting of HasMany children list

Dear all

The evolutions in the way Administrate handle sorting within the dashboards makes the gem flexible and super useful. However, there is still a particular case which is not managed and which prevents me from having an administration tool entirely based on the configuration files of Administrator. : being able to reorder manually the list of children within a HasMany relation, based on a specific position attribute.

use case : I have an album template that contains many images. These images must be ordered manually by the person in charge of the album, according to his artistic touch, the story he wishes to tell.

I feel that this feature is probably cumbersome to implement, since it would likely impact pagination and other well-established features and add specific behavior regarding the existing/non existing positions when children's data are imported. Acts_as_list had a bunch of methods allowing things like this I guess.

However, I have the intuition that such an ordering solution, which corresponds well to a data administration action, would be useful for the management of many data models.

In the case of a "simple" HasMany relationship, it would suffice to pass two pieces of information to the dashboard: specify the classification mode and specify the name of the attribute that contains the position of each child.

  ATTRIBUTE_TYPES = {
    pictures: Field::HasMany.with_options(sortable: true, sortable_index_position: :position),
  }.freeze

A last option could allow to specify the method of interaction allowing to modify the classification if there were several.

I hope this idea will interest some of you :)

Assignee
Assign to
Time tracking