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

Reset "page" param on "per_page" change #528

Conversation

steffengodskesen
Copy link

Example:

Go to: http://demo.projectblacklight.org/?f%5Bformat%5D%5B%5D=Unknown&per_page=10
Change to page 2: http://demo.projectblacklight.org/?f%5Bformat%5D%5B%5D=Unknown&page=2&per_page=10
Change "per_page" to 100: http://demo.projectblacklight.org/?f%5Bformat%5D%5B%5D=Unknown&page=2&per_page=100

Now you're stuck on results "101 - 100 of 88" with a blank page and no next/prev links.

Our solution: When the "per_page" param is changed, reset the "page" param to 1,
to avoid paging outside the actual number of documents. Also disable
the link for selecting the "per_page" value that is currently active.

When the "per_page" param is changed, reset the "page" param to 1,
to avoid paging outside the actual number of documents. Also disable
the link for selecting the "per_page" value that is currently active.
@steffengodskesen
Copy link
Author

Build failure seems to be caused by #527

@cbeer
Copy link
Member

cbeer commented Feb 13, 2013

The used to be the case, I think. I'd like to see some tests to ensure it remains true.

@steffengodskesen
Copy link
Author

Sure. I'll try to come up with a test or two. It seems easiest to expand on search.feature and search.steps. Maybe extract into search_paging.feature/search_paging.steps. Would that be ok?

@cbeer
Copy link
Member

cbeer commented Feb 13, 2013

Sounds reasonable to me. I also wonder if we could/should push the business logic into params_for_search and just unit-test it?

@steffengodskesen
Copy link
Author

When I first started, I tried (although not very hard) to find somewhere else to put some logic that would determine if "per_page" had changed and then reset "page", but what happens in the before_filters in Blacklight::Catalog#search_session and Blacklight::Catalog#delete_or_assign_search_session_params kind stopped me on that track.

If you have a rough sketch of an implementation, I'll be happy to have a go on it.

I'll work a bit on the tests. If I do it right, they should be valid independent of the implementation.

@cbeer
Copy link
Member

cbeer commented Feb 13, 2013

+1

@steffengodskesen
Copy link
Author

Hang on while I fix something. I broke the layout in the sort dropdown.

@cbeer cbeer closed this in aa5a40d Feb 21, 2013
@cbeer
Copy link
Member

cbeer commented Feb 21, 2013

I cherry-picked your tests (thanks!) and pushed the actual logic into the #params_for_search method itself.

@steffengodskesen
Copy link
Author

Cool. Thanks.

Something similar is happening when you remove a query constraint. When removing facet constraints, the page param is correctly reset/removed, but not when removing a query constraint.

I'm going to try and have a look at it today.

Steffen

On Friday, February 22, 2013 at 00:13 , Chris Beer wrote:

I cherry-picked your tests (thanks!) and pushed the actual logic into the #params_for_search method itself.


Reply to this email directly or view it on GitHub (#528 (comment)).

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.

None yet

2 participants