diff --git a/app/assets/stylesheets/alchemy/search.scss b/app/assets/stylesheets/alchemy/search.scss
index fb4b38dbb3..5bef78116f 100644
--- a/app/assets/stylesheets/alchemy/search.scss
+++ b/app/assets/stylesheets/alchemy/search.scss
@@ -11,9 +11,19 @@
top: 9px;
}
- label {
- display: block;
+ button {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 30px;
height: inherit;
+ appearance: none;
+ background-color: transparent;
+ border: 0 none;
+ border-radius: 0;
+ box-shadow: none;
+ margin: 0;
+ padding: 0;
}
}
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 4df6521bf8..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,24 +1,25 @@
-<%= 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) %>
-
- <%= link_to render_icon(:times, size: 'xs'), url_for(
+
+ <%= f.search_field resource_handler.search_field_name,
+ placeholder: Alchemy.t(:search),
+ class: 'search_input_field',
+ id: nil %>
+ <%= 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 995ef95dea..d6abdf8087 100644
--- a/app/views/alchemy/admin/partials/_search_form.html.erb
+++ b/app/views/alchemy/admin/partials/_search_form.html.erb
@@ -1,13 +1,13 @@
-<%- 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| %>
-
+
+ <%= f.search_field resource_handler.search_field_name,
+ class: 'search_input_field',
+ placeholder: Alchemy.t(:search) %>
<% local_assigns.fetch(:additional_query_fields, []).each do |field| %>
<%= f.hidden_field field %>
<% end %>
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