Issue Details (XML | Word | Printable)

Key: CODEBASE-213
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jonathan Rochkind
Reporter: Jonathan Rochkind
Votes: 0
Watchers: 0
Operations

Clone this issue
If you were logged in you would be able to see more operations.
Blacklight Plugin

New search_field request parameter not preserved on sort change

Created: 15/Apr/10 11:25 AM   Updated: 15/Apr/10 04:27 PM
Return to search
Component/s: None
Affects Version/s: 2.4
Fix Version/s: 2.5


 Description  « Hide
The new search fields Solr parameterization adds a :search_fields request parameter.

But changing sort order in the results view loses this search_fields, so you end up seeing different results for the default search when you change sort order.

Need to investigate, but it sounds like the sort order change is only keeping _particular_ parameters on switch. I suggest it should be changed to _exclude_ particular parameters (mainly :page), and keep everything else -- this will be less fragile, and better accomodate additional request parameters added by extensions like advanced search.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Jonathan Rochkind added a comment - 15/Apr/10 12:36 PM
Boy, the weird f[] stuff in the request parameters makes it hard to do this cleanly and DRY.

Jonathan Rochkind added a comment - 15/Apr/10 04:27 PM
Fixed and committed.

There is a helper method search_as_hidden_fields which will take the current request params and turn them into hidden form fields, with hash's and arrays done in Rails style. This uses the new HashAsHiddenFields helper that I found on google. This method takes an optional argument of certain keys to admit (:sort, :per_page, :page, etc).

search_form and sort_and_per_page both use this method now, nice and DRY. This method includes ALL existing params _except_ certain specified ones to omit -- so it's nice and future-proofed for future extensions that add more request keys that need to be preserved (like advanced search field).

The former _hidden_filters partial is removed, it is now handled fine by the more general #search_as_hidden_fields

specs for all new methods, feature testing that this issue is indeed resolved.

Jonathan Rochkind made changes - 15/Apr/10 04:27 PM
Field Original Value New Value
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]