diff --git a/app/views/alchemy/admin/partials/_remote_search_form.html.erb b/app/views/alchemy/admin/partials/_remote_search_form.html.erb index c427148497..aae009426b 100644 --- a/app/views/alchemy/admin/partials/_remote_search_form.html.erb +++ b/app/views/alchemy/admin/partials/_remote_search_form.html.erb @@ -1,6 +1,7 @@ -<%= search_form_for @query, url: url_for( - action: 'index', - size: @size +<%= search_form_for @query, url: url_for({ + action: 'index', + size: @size, + }.merge(search_filter_params.except(:q)) ), remote: true, html: {class: 'search_form', id: nil} do |f| %> <%= hidden_field_tag("element_id", @element.blank? ? "" : @element.id) %> <%= hidden_field_tag("content_id", @content.blank? ? "" : @content.id) %> @@ -12,13 +13,13 @@ placeholder: Alchemy.t(:search), class: 'search_input_field', id: nil %> - <%= link_to render_icon(:times, size: 'xs'), url_for( + <%= link_to render_icon(:times, size: 'xs'), url_for({ action: 'index', element_id: @element.blank? ? '' : @element.id, content_id: @content.blank? ? '' : @content.id, size: @size, overlay: true - ), + }.merge(search_filter_params.except(:q))), remote: true, class: 'search_field_clear', title: Alchemy.t(:click_to_show_all), diff --git a/app/views/alchemy/admin/partials/_search_form.html.erb b/app/views/alchemy/admin/partials/_search_form.html.erb index de5fd05651..d6abdf8087 100644 --- a/app/views/alchemy/admin/partials/_search_form.html.erb +++ b/app/views/alchemy/admin/partials/_search_form.html.erb @@ -1,4 +1,4 @@ -<%- url ||= resource_url_proxy.url_for(action: 'index') -%> +<%- url ||= resource_url_proxy.url_for({ action: 'index' }.merge(search_filter_params.except(:q))) -%> <%= search_form_for @query, url: url, class: 'search_form' do |f| %>
diff --git a/app/views/alchemy/admin/resources/index.html.erb b/app/views/alchemy/admin/resources/index.html.erb index c3659f7bd5..21e7413335 100644 --- a/app/views/alchemy/admin/resources/index.html.erb +++ b/app/views/alchemy/admin/resources/index.html.erb @@ -21,7 +21,10 @@ dialog: false, if_permitted_to: [:index, resource_model] ) %> - <%= render 'alchemy/admin/partials/search_form' %> + <%= render 'alchemy/admin/partials/search_form', additional_params: [ + resource_has_filters ? :filter : nil, + resource_has_tags ? :tagged_with : nil + ].compact %> <% end %>
diff --git a/spec/features/admin/resources_integration_spec.rb b/spec/features/admin/resources_integration_spec.rb index 0e1fffe762..40a6e6117e 100644 --- a/spec/features/admin/resources_integration_spec.rb +++ b/spec/features/admin/resources_integration_spec.rb @@ -222,5 +222,22 @@ expect(page).to have_content("Hovercar Expo") expect(page).to have_content("Horse Expo") end + + context "full text search" do + it "should respect filters" do + visit "/admin/events?filter=future" + + expect(page).to have_content("Hovercar Expo") + expect(page).to_not have_content("Car Expo") + expect(page).to_not have_content("Horse Expo") + + page.find(".search_input_field").set("Horse") + page.find(".search_field button").click + + expect(page).to_not have_content("Hovercar Expo") + expect(page).to_not have_content("Car Expo") + expect(page).to_not have_content("Horse Expo") + end + end end end