-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
Append sort params on pagination links only when explicitly given in `@conn.assigns`
There was a problem hiding this 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.
priv/templates/elixir/controller.ex
Outdated
@@ -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 %>") |
There was a problem hiding this comment.
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 %>")
@danielberkompas I think d2baab9 addresses your feedback. Can you approve and merge? |
@darin yep, sorry about the delay! Didn't mean to ignore this. |
@danielberkompas No worries - thanks! 👍 |
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