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

page query string is blank when using the sorting #22

Closed
yulolimum opened this issue Sep 9, 2016 · 4 comments
Closed

page query string is blank when using the sorting #22

yulolimum opened this issue Sep 9, 2016 · 4 comments
Assignees
Labels

Comments

@yulolimum
Copy link
Contributor

Clicking on a table heading appends query strings to the URL in order to sort the data items. It should add a sort_field and sort_direction key to the params (which it does). However, it also adds a page key which is blank.

Here are relevant code snippets:

We are passing in opts with no page key here:

We are setting the page key here - in this case it's nil because i dont have page in the assigns:

This results in the following error:

Am I missing something? Do I have to set the page key on the conn in the controller?

@yulolimum
Copy link
Contributor Author

yulolimum commented Sep 9, 2016

Hmmm... I decided to remove the page key manually and now i'm getting a different error:

{:ok, filter} = Filtrex.parse_params(@filtrex, Map.delete(params, "page") || %{})

getting...

Did something get generated incorrectly?

@yulolimum
Copy link
Contributor Author

@darinwilson - do you have issues with sorting? If not, which project are you on so I can compare controllers?

@yulolimum
Copy link
Contributor Author

I ended up adding my own sort since I'm not really using the sidebar widgets for filtering.

    page =
      User
      |> order_by(^sort_order(params["sort_direction"], params["sort_field"]))
      |> paginate(Repo, params, @pagination)
  defp sort_order(direction, field) when is_binary(direction) and is_binary(field) do
    [{String.to_atom(direction), String.to_atom(field)}]
  end
  defp sort_order(_, _), do: [desc: :inserted_at]

leaving this open just so someone can verify that's torch isn't having issues out of the box.

@danielberkompas
Copy link
Contributor

I'm pretty sure I encountered this in CrossConnect. Gonna copy over some of my fixes from over there.

danielberkompas added a commit that referenced this issue Nov 26, 2016
These changes allow the query string to be preserved with pagination, so
you can start a search and then page through the results.
danielberkompas added a commit that referenced this issue Nov 26, 2016
The templates in the `apps/example` app needed to be regenerated using
the `mix regenerate` command.
@danielberkompas danielberkompas self-assigned this Nov 26, 2016
danielberkompas added a commit that referenced this issue Mar 11, 2017
These changes allow the query string to be preserved with pagination, so
you can start a search and then page through the results.
danielberkompas added a commit that referenced this issue Mar 11, 2017
The templates in the `apps/example` app needed to be regenerated using
the `mix regenerate` command.
danielberkompas added a commit that referenced this issue Mar 11, 2017
danielberkompas added a commit that referenced this issue Mar 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants