Commit 35018fd29e826dcc12fcbec76f586139a59fade8
1 parent
0321263b
Adding partial renders to update links and input text
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
Showing
8 changed files
with
51 additions
and
40 deletions
Show diff stats
plugins/elasticsearch/public/javascripts/categories.js
... | ... | @@ -19,7 +19,6 @@ var main = function() { |
19 | 19 | dataParams[item[0]] = item[1]; |
20 | 20 | }); |
21 | 21 | |
22 | - | |
23 | 22 | var idx = categories.indexOf(this.value); |
24 | 23 | if (idx == -1) { |
25 | 24 | categories.push(this.value); |
... | ... | @@ -27,15 +26,12 @@ var main = function() { |
27 | 26 | categories.splice(idx, 1); |
28 | 27 | } |
29 | 28 | |
29 | + dataParams['categories'] = categories.join(",") | |
30 | + | |
30 | 31 | $.ajax({ |
31 | 32 | method: "GET", |
32 | 33 | url: "/search?format=js", |
33 | - data: { | |
34 | - categories: categories.join(","), | |
35 | - selected_type: dataParams["selected_type"], | |
36 | - filter: dataParams["filter"], | |
37 | - query: dataParams["query"] | |
38 | - } | |
34 | + data: dataParams | |
39 | 35 | }); |
40 | 36 | }); |
41 | 37 | }; | ... | ... |
plugins/elasticsearch/public/style.css
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | |
53 | 53 | .controller-elasticsearch_plugin #content-inner .categories, |
54 | 54 | .controller-elasticsearch_plugin #content-inner .search-filter, |
55 | -.controller-elasticsearch_plugin #content-inner ul.search-options { | |
55 | +.controller-elasticsearch_plugin #content-inner .search-options ul { | |
56 | 56 | background: #fff; |
57 | 57 | overflow: hidden; |
58 | 58 | border-radius: 5px; | ... | ... |
plugins/elasticsearch/views/elasticsearch_plugin/_results_count.html.erb
0 → 100644
plugins/elasticsearch/views/elasticsearch_plugin/_search_field.html.erb
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +<%= form_tag '/plugin/elasticsearch/search', method: :get do %> | |
2 | + | |
3 | + <%= hidden_field_tag("selected_type", @selected_type) if @selected_type %> | |
4 | + | |
5 | + <%= hidden_field_tag("filter", @selected_sort) if @selected_sort %> | |
6 | + | |
7 | + <%= hidden_field_tag("categories", @selected_categories.join(",")) if @selected_categories %> | |
8 | + | |
9 | + <%= text_field_tag :query, @query %> | |
10 | + | |
11 | + <%= submit_tag _("Send") %> | |
12 | +<% end %> | ... | ... |
plugins/elasticsearch/views/elasticsearch_plugin/_search_filter.html.erb
0 → 100644
... | ... | @@ -0,0 +1,8 @@ |
1 | +<h3 class="box-title"><%= _("Sort by") %></h3> | |
2 | +<ul> | |
3 | +<% for type, value in @sort_types %> | |
4 | + <li class="select-search-type <%= "active" if type == @selected_sort %>"> | |
5 | + <%= link_to value[:label], "?selected_type=#{@selected_type}&query=#{@query}&filter=#{type}&categories=#{@selected_categories.join(',')}" %> | |
6 | + </li> | |
7 | +<% end %> | |
8 | +</ul> | ... | ... |
plugins/elasticsearch/views/elasticsearch_plugin/_search_option.html.erb
0 → 100644
... | ... | @@ -0,0 +1,7 @@ |
1 | +<ul> | |
2 | + <% for type,value in @searchable_types %> | |
3 | + <li class="select-search-type <%= "active" if type == @selected_type %>"> | |
4 | + <%= link_to value[:label], "?selected_type=#{type}&query=#{@query}&categories=#{@selected_categories.join(',')}"%> | |
5 | + </li> | |
6 | + <% end %> | |
7 | +</ul> | ... | ... |
plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb
1 | 1 | <div class="wrapper"> |
2 | 2 | <div class="search_form"> |
3 | 3 | <div class="search_field"> |
4 | - <%= form_tag '/plugin/elasticsearch/search', method: :get do %> | |
5 | - <%= hidden_field_tag "selected_type", @selected_type %> | |
6 | - <% if @selected_filter %> | |
7 | - <%= hidden_field_tag "filter", @selected_filter %> | |
8 | - <% end %> | |
9 | - <%= text_field_tag :query, @query %> | |
10 | - <%= submit_tag _("Send") %> | |
11 | - <% end %> | |
4 | + <%= render :partial => "search_field" %> | |
12 | 5 | </div> |
13 | 6 | <div class="results-count"> |
14 | - <p> | |
15 | - <strong><%= @hits %></strong> | |
16 | - <% if not @query.blank? %> | |
17 | - <%= _(" results for ") %><%= @query %> | |
18 | - <% else %> | |
19 | - <%= _(" total results") %> | |
20 | - <% end %> | |
21 | - </p> | |
7 | + <%= render :partial => "results_count" %> | |
22 | 8 | </div> |
23 | 9 | </div> |
24 | 10 | |
25 | 11 | <div class="results-wrapper"> |
26 | 12 | <div class="sidebar"> |
27 | - <ul class="search-options"> | |
28 | - <% for type,value in @searchable_types %> | |
29 | - <li class="select-search-type <%= "active" if type == @selected_type %>"> | |
30 | - <%= link_to value[:label], "?selected_type=#{type}&query=#{@query}&categories=#{@selected_categories.join(',')}"%> | |
31 | - </li> | |
32 | - <% end %> | |
33 | - </ul> | |
13 | + | |
14 | + <div class="search-options"> | |
15 | + <%= render :partial => "search_option.html.erb" %> | |
16 | + </div> | |
17 | + | |
34 | 18 | <div class="search-filter"> |
35 | - <h3 class="box-title"><%= _("Sort by") %></h3> | |
36 | - <ul> | |
37 | - <% for type, value in @sort_types %> | |
38 | - <li class="select-search-type <%= "active" if type == @selected_sort %>"> | |
39 | - <%= link_to value[:label], "?selected_type=#{@selected_type}&query=#{@query}&filter=#{type}&categories=#{@selected_categories.join(',')}" %> | |
40 | - </li> | |
41 | - <% end %> | |
42 | - </ul> | |
19 | + <%= render :partial => "search_filter.html.erb" %> | |
43 | 20 | </div> |
44 | 21 | |
45 | 22 | <div class="categories"> | ... | ... |
plugins/elasticsearch/views/elasticsearch_plugin/search.js.erb
1 | 1 | $(".results").html("<%= escape_javascript(render partial: 'search_collection') %>"); |
2 | - | |
2 | +$(".results-count").html("<%= escape_javascript(render partial: 'results_count') %>"); | |
3 | +$(".search-options").html("<%= escape_javascript(render partial: 'search_option') %>"); | |
4 | +$(".search-filter").html("<%= escape_javascript(render partial: 'search_filter') %>"); | |
5 | +$(".search_field").html("<%= escape_javascript(render partial: 'search_field') %>"); | ... | ... |