diff --git a/plugins/elasticsearch/public/javascripts/categories.js b/plugins/elasticsearch/public/javascripts/categories.js index de2eeef..62a82d1 100644 --- a/plugins/elasticsearch/public/javascripts/categories.js +++ b/plugins/elasticsearch/public/javascripts/categories.js @@ -19,7 +19,6 @@ var main = function() { dataParams[item[0]] = item[1]; }); - var idx = categories.indexOf(this.value); if (idx == -1) { categories.push(this.value); @@ -27,15 +26,12 @@ var main = function() { categories.splice(idx, 1); } + dataParams['categories'] = categories.join(",") + $.ajax({ method: "GET", url: "/search?format=js", - data: { - categories: categories.join(","), - selected_type: dataParams["selected_type"], - filter: dataParams["filter"], - query: dataParams["query"] - } + data: dataParams }); }); }; diff --git a/plugins/elasticsearch/public/style.css b/plugins/elasticsearch/public/style.css index 900de26..47eeea5 100644 --- a/plugins/elasticsearch/public/style.css +++ b/plugins/elasticsearch/public/style.css @@ -52,7 +52,7 @@ .controller-elasticsearch_plugin #content-inner .categories, .controller-elasticsearch_plugin #content-inner .search-filter, -.controller-elasticsearch_plugin #content-inner ul.search-options { +.controller-elasticsearch_plugin #content-inner .search-options ul { background: #fff; overflow: hidden; border-radius: 5px; diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/_results_count.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/_results_count.html.erb new file mode 100644 index 0000000..7ddbcd5 --- /dev/null +++ b/plugins/elasticsearch/views/elasticsearch_plugin/_results_count.html.erb @@ -0,0 +1,8 @@ +

+ <%= @hits %> + <% if not @query.blank? %> + <%= _(" results for ") %><%= @query %> + <% else %> + <%= _(" total results") %> + <% end %> +

diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/_search_field.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/_search_field.html.erb new file mode 100644 index 0000000..288f331 --- /dev/null +++ b/plugins/elasticsearch/views/elasticsearch_plugin/_search_field.html.erb @@ -0,0 +1,12 @@ +<%= form_tag '/plugin/elasticsearch/search', method: :get do %> + + <%= hidden_field_tag("selected_type", @selected_type) if @selected_type %> + + <%= hidden_field_tag("filter", @selected_sort) if @selected_sort %> + + <%= hidden_field_tag("categories", @selected_categories.join(",")) if @selected_categories %> + + <%= text_field_tag :query, @query %> + + <%= submit_tag _("Send") %> +<% end %> diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/_search_filter.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/_search_filter.html.erb new file mode 100644 index 0000000..095a172 --- /dev/null +++ b/plugins/elasticsearch/views/elasticsearch_plugin/_search_filter.html.erb @@ -0,0 +1,8 @@ +

<%= _("Sort by") %>

+ diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/_search_option.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/_search_option.html.erb new file mode 100644 index 0000000..b85cbbb --- /dev/null +++ b/plugins/elasticsearch/views/elasticsearch_plugin/_search_option.html.erb @@ -0,0 +1,7 @@ + diff --git a/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb b/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb index 6f477cc..1f907b4 100644 --- a/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb +++ b/plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb @@ -1,45 +1,22 @@
- <%= form_tag '/plugin/elasticsearch/search', method: :get do %> - <%= hidden_field_tag "selected_type", @selected_type %> - <% if @selected_filter %> - <%= hidden_field_tag "filter", @selected_filter %> - <% end %> - <%= text_field_tag :query, @query %> - <%= submit_tag _("Send") %> - <% end %> + <%= render :partial => "search_field" %>
-

- <%= @hits %> - <% if not @query.blank? %> - <%= _(" results for ") %><%= @query %> - <% else %> - <%= _(" total results") %> - <% end %> -

+ <%= render :partial => "results_count" %>