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

Add ability to set default sort order #55

Merged
merged 5 commits into from
May 30, 2017
Merged

Add ability to set default sort order #55

merged 5 commits into from
May 30, 2017

Conversation

morgandonze
Copy link
Contributor

@morgandonze morgandonze commented May 22, 2017

The default sort order for a model in the admin can be set during generation. This is done by passing the sort field and sort direction as the last argument before the attributes when running mix torch.gen.

For example:
mix torch.gen eex Admin Post posts inserted_at desc title:string body:text inserted_at:date

Fixes #32

Morgan Laco added 3 commits May 19, 2017 20:43
Append sort params on pagination links only when explicitly given in `@conn.assigns`
Copy link
Contributor

@danielberkompas danielberkompas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One change.

@@ -21,6 +21,11 @@ defmodule <%= module %>Controller do
@pagination_distance 5

def index(conn, params) do
params = Map.put_new(params, "sort_direction", "<%= sort_direction %>")
params = Map.put_new(params, "sort_field", "<%= sort_field %>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good place to have a pipeline.

params =
  params
  |> Map.put_new("sort_direction", "<%= sort_direction %>")
  |> Map.put_new("sort_field", "<%= sort_field %>")

@darinwilson
Copy link
Contributor

@danielberkompas I think d2baab9 addresses your feedback. Can you approve and merge?

@danielberkompas danielberkompas merged commit 06b527a into master May 30, 2017
@danielberkompas
Copy link
Contributor

@darin yep, sorry about the delay! Didn't mean to ignore this.

@darinwilson
Copy link
Contributor

@danielberkompas No worries - thanks! 👍

@cpjolicoeur cpjolicoeur deleted the sort_order branch September 13, 2019 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants