avo icon indicating copy to clipboard operation
avo copied to clipboard

Default sort by for resource

Open adrianthedev opened this issue 1 year ago • 1 comments

Discussed in https://github.com/avo-hq/avo/discussions/2553

Originally posted by krystof-k March 3, 2024 It would be great if it would be possible to set default sorting for a resource, for example something like:

  def fields
    field :created_at,
      as: :date_time,
      disabled: true,
      sortable: true,
      sort_by_default: :desc
  end

adrianthedev avatar Mar 15 '24 15:03 adrianthedev

For index when visiting resource

self.index_query = -> { query.order(created_at: :desc) }

For index when rendered on association

field :users, as: :has_many, scope: -> { query.order(created_at: :desc) }

Paul-Bob avatar Mar 18 '24 06:03 Paul-Bob

Picking this up.

Yash-Singh-Pathania avatar Jul 16 '24 07:07 Yash-Singh-Pathania

Hello @Yash-Git-Hub we decided to go with a global configuration as specified in this issue https://github.com/avo-hq/avo/issues/2982 and it's already assigned to @iamworrell

Let's continue the conversation there.

Closing in favor of https://github.com/avo-hq/avo/issues/2982

Paul-Bob avatar Jul 16 '24 08:07 Paul-Bob