Commit 35018fd29e826dcc12fcbec76f586139a59fade8

Authored by Macartur Sousa
1 parent 0321263b
Exists in error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0 and in 42 other branches error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0, error: Could not read b8e82215186a07298d27835f187adb84c8b77eb0

Adding partial renders to update links and input text

Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
plugins/elasticsearch/public/javascripts/categories.js
@@ -19,7 +19,6 @@ var main = function() { @@ -19,7 +19,6 @@ var main = function() {
19 dataParams[item[0]] = item[1]; 19 dataParams[item[0]] = item[1];
20 }); 20 });
21 21
22 -  
23 var idx = categories.indexOf(this.value); 22 var idx = categories.indexOf(this.value);
24 if (idx == -1) { 23 if (idx == -1) {
25 categories.push(this.value); 24 categories.push(this.value);
@@ -27,15 +26,12 @@ var main = function() { @@ -27,15 +26,12 @@ var main = function() {
27 categories.splice(idx, 1); 26 categories.splice(idx, 1);
28 } 27 }
29 28
  29 + dataParams['categories'] = categories.join(",")
  30 +
30 $.ajax({ 31 $.ajax({
31 method: "GET", 32 method: "GET",
32 url: "/search?format=js", 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,7 +52,7 @@
52 52
53 .controller-elasticsearch_plugin #content-inner .categories, 53 .controller-elasticsearch_plugin #content-inner .categories,
54 .controller-elasticsearch_plugin #content-inner .search-filter, 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 background: #fff; 56 background: #fff;
57 overflow: hidden; 57 overflow: hidden;
58 border-radius: 5px; 58 border-radius: 5px;
plugins/elasticsearch/views/elasticsearch_plugin/_results_count.html.erb 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<p>
  2 + <strong><%= @hits %></strong>
  3 + <% if not @query.blank? %>
  4 + <%= _(" results for ") %><%= @query %>
  5 + <% else %>
  6 + <%= _(" total results") %>
  7 + <% end %>
  8 +</p>
plugins/elasticsearch/views/elasticsearch_plugin/_search_field.html.erb 0 → 100644
@@ -0,0 +1,12 @@ @@ -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 @@ @@ -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 @@ @@ -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 <div class="wrapper"> 1 <div class="wrapper">
2 <div class="search_form"> 2 <div class="search_form">
3 <div class="search_field"> 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 </div> 5 </div>
13 <div class="results-count"> 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 </div> 8 </div>
23 </div> 9 </div>
24 10
25 <div class="results-wrapper"> 11 <div class="results-wrapper">
26 <div class="sidebar"> 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 <div class="search-filter"> 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 </div> 20 </div>
44 21
45 <div class="categories"> 22 <div class="categories">
plugins/elasticsearch/views/elasticsearch_plugin/search.js.erb
1 $(".results").html("<%= escape_javascript(render partial: 'search_collection') %>"); 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') %>");