Commit 2054f391a37c74f00da92c1781d75f48407e8ff0

Authored by Dylan Guedes
Committed by Macartur Sousa
1 parent e578728c
Exists in elasticsearch_sort

Changes style of elasticsearch plugin, add variable to store search types.

Signed-off-by: DylanGuedes <djmgguedes@gmail.com>
Signed-off-by: Macartur Sousa <marcartur.sc@gmail.com>
plugins/elasticsearch/controllers/elasticsearch_plugin_controller.rb
1 1 class ElasticsearchPluginController < ApplicationController
2 2 no_design_blocks
3 3  
4   - SEARCHABLE_TYPES = { :all => { label: "All Results" },
5   - :community => { label: "Communities"},
6   - :article => { label: "Articles"},
7   - :event => { label: "Events"},
8   - :person => { label: "People"}
  4 + SEARCHABLE_TYPES = { :all => { label: _("All Results")},
  5 + :community => { label: _("Communities")},
  6 + :article => { label: _("Articles")},
  7 + :event => { label: _("Events")},
  8 + :person => { label: _("People")}
9 9 }
  10 + SEARCH_FILTERS = { :lexical => { label: _("Alphabetical Order")},
  11 + :recent => { label: _("More Recent Order")},
  12 + :access => { label: _("More accessed")}
  13 + }
10 14  
11 15 def index
12 16 search()
... ... @@ -16,6 +20,7 @@ class ElasticsearchPluginController &lt; ApplicationController
16 20 def search
17 21 @searchable_types = SEARCHABLE_TYPES
18 22 @selected_type = selected_type params
  23 + @search_filter_types = SEARCH_FILTERS
19 24  
20 25 @query = params[:q]
21 26 @results = []
... ...
plugins/elasticsearch/public/style.css
... ... @@ -9,4 +9,31 @@
9 9 flex: 1;
10 10 }
11 11  
  12 +.controller-elasticsearch_plugin ul {
  13 + list-style: none;
  14 + list-style-position: inside;
  15 + padding-left: 0px;
  16 +}
12 17  
  18 +.controller-elasticsearch_plugin .select-search-type {
  19 + padding: 10px;
  20 + margin: 10px;
  21 + font-weight: 900;
  22 + font-family: arial;
  23 + border: 1px solid #ddd;
  24 + margin-top: 0px;
  25 + margin-bottom: 0px;
  26 +}
  27 +.controller-elasticsearch_plugin .select-search-type.active {
  28 + padding: 10px;
  29 + background: #ccc;
  30 + margin-left: 10px;
  31 + margin-right: 10px;
  32 + font-weight: 900;
  33 + font-family: arial;
  34 +}
  35 +
  36 +.controller-elasticsearch_plugin .select-search-type a {
  37 + text-decoration: none;
  38 + color: black;
  39 +}
... ...
plugins/elasticsearch/views/elasticsearch_plugin/search.html.erb
... ... @@ -3,16 +3,25 @@
3 3 <div class="sidebar">
4 4 <%= @results.count %>
5 5 <ul>
  6 + <li class="select-search-type active"><a href="#"> <%= @searchable_types.values[0][:label] %></a></li>
6 7 <% for type in @searchable_types.values %>
7   - <li><a class=""> <%= type[:label] %></a></li>
  8 + <li class="select-search-type"><a href="#"> <%= type[:label] %></a></li>
8 9 <% end %>
9 10 </ul>
  11 +
  12 + <div class="search-filter">
  13 + <h3><%= _("Filter by") %></h3>
  14 + <ul>
  15 + <% for type in @search_filter_types.values %>
  16 + <li><a href="#"><%= type[:label] %></a></li>
  17 + <% end %>
  18 + </ul>
  19 + </div>
10 20 </div>
11 21  
12 22 <div class="search_form">
13 23 <div class="search_field">
14 24 <%= form_tag controller: "elasticsearch_plugin", action: "search" do %>
15   - <%= label_tag(:q, _("Search")) %>
16 25 <%= text_field_tag(:q, @query) %>
17 26  
18 27 <%= submit_tag _("Send") %>
... ...