diff options
-rw-r--r-- | app/controllers/public_body_controller.rb | 2 | ||||
-rw-r--r-- | app/views/public_body/_search_ahead.rhtml | 1 | ||||
-rw-r--r-- | app/views/request/select_authority.rhtml | 2 | ||||
-rw-r--r-- | lib/willpaginate_extension.rb | 6 |
4 files changed, 8 insertions, 3 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index c31134641..94d1351db 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -185,7 +185,7 @@ class PublicBodyController < ApplicationController def search_typeahead # Since acts_as_xapian doesn't support the Partial match flag, we work around it # by making the last work a wildcard, which is quite the same - query = params[:q] + query = params[:query] query = query.split(' ') if query.last.nil? || query.last.strip.length < 3 @xapian_requests = nil diff --git a/app/views/public_body/_search_ahead.rhtml b/app/views/public_body/_search_ahead.rhtml index 436471544..484d28256 100644 --- a/app/views/public_body/_search_ahead.rhtml +++ b/app/views/public_body/_search_ahead.rhtml @@ -13,6 +13,7 @@ <%= render :partial => 'body_listing_single', :locals => { :public_body => result[:model] } %> <% end %> </div> + <%= will_paginate WillPaginate::Collection.new(@page, 10, @xapian_requests.matches_estimated) %> <% end %> </p> diff --git a/app/views/request/select_authority.rhtml b/app/views/request/select_authority.rhtml index 1e78168e9..9aaa37f4d 100644 --- a/app/views/request/select_authority.rhtml +++ b/app/views/request/select_authority.rhtml @@ -7,7 +7,7 @@ // http://benalman.com/projects/jquery-throttle-debounce-plugin/ $("#query").keypress($.debounce( 300, function() { // Do a type ahead search and display results - $("#typeahead_response").load("<%=search_ahead_bodies_url%>?q="+encodeURI(this.value), function() { + $("#typeahead_response").load("<%=search_ahead_bodies_url%>?query="+encodeURI(this.value), function() { $("#authority_preview").hide(); // Hide the preview, since results have changed }); diff --git a/lib/willpaginate_extension.rb b/lib/willpaginate_extension.rb index 912748957..4588b5256 100644 --- a/lib/willpaginate_extension.rb +++ b/lib/willpaginate_extension.rb @@ -5,9 +5,13 @@ module WillPaginateExtension # Hack for admin pages, when proxied via https on mySociety servers, they # need a relative URL. url = url_for(page) - if url.match(/^\/admin.*(\?.*)/) + if url.match(/\/admin.*(\?.*)/) url = $1 end + # Hack around our type-ahead search magic + if url.match(/\/body\/search_ahead/) + url.sub!("/body/search_ahead", "/select_authority") + end @template.link_to text, url, attributes end |