faceted_search 3.5.7 → 3.5.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80006422a406840a486d9c8f5a50e1a2425057b285af095e95ee359021a1c1d7
4
- data.tar.gz: 578682f035d0315fe84a4950e78879eb0f9654b5d9ff2582b091672473c517ff
3
+ metadata.gz: 1ada6583674e8af506d38ff4d6210031a2c26e36b272d81dcfcc294d771c11b8
4
+ data.tar.gz: c0ecb0db4418a381bdef93b05e1ea8f69a4b71dcb71c05cc04e5729cb0e41b24
5
5
  SHA512:
6
- metadata.gz: ee0870c176285f42f78bb0c244a52783dcc54733b1d0ad1fc5a3db88b069b72d0222bc2c87b6873fd1b503f5d5b2f58f6782c905963d38ece704ded9b5b21c0d
7
- data.tar.gz: f0f3ab3e4019737a2d48a364f74b82bc449a1d8d26f94972d3830dcf8334b61b2d473026832cec7d6247ac8bf88eb59e68f0e03237c6e30e54d88a091d199b5b
6
+ metadata.gz: c5618af51815c11964bcf5e17247000c50856a440b30582451382067f3c987df98258b8eb18a2b2d2e08705038f2c508e440e71a377cda146797b60730943f74
7
+ data.tar.gz: f10e4f886e2097bc67175dd95f29af2afc817bd101f5e2f9e9617743068c736b6ceb908d2051d8085a841e37a6e55d8d2132f0119dee3f7d28fa3dae5d086b41
@@ -26,7 +26,10 @@ module FacetedSearch
26
26
  end
27
27
 
28
28
  def values
29
- @values ||= order == :asc ? source : source.reverse
29
+ @values ||= begin
30
+ values = (source | params_array.map(&:to_i)).sort
31
+ order == :asc ? values : values.reverse
32
+ end
30
33
  end
31
34
  end
32
35
  end
@@ -29,7 +29,8 @@ module FacetedSearch
29
29
  @values ||= begin
30
30
  joined_table = facets.model_table_name.to_sym
31
31
  results = params_array.blank? ? facets.results : facets.results_except(@name)
32
- source.all.joins(joined_table).where(joined_table => { id: results }).distinct
32
+ values = source.all.joins(joined_table)
33
+ values.where(joined_table => { id: results }).or(values.where(id: params_array)).distinct
33
34
  end
34
35
  end
35
36
 
@@ -31,7 +31,7 @@ module FacetedSearch
31
31
 
32
32
  def values
33
33
  @values ||= begin
34
- values = source.pluck(field).uniq.reject(&:blank?).sort
34
+ values = (source.pluck(field).uniq.reject(&:blank?) | params_array.compact).sort
35
35
  order == :asc ? values : values.reverse
36
36
  end
37
37
  end
@@ -8,7 +8,18 @@ module FacetedSearch
8
8
 
9
9
  def add_scope(scope)
10
10
  return scope if params.blank?
11
- scope.where("#{facets.model_table_name}.#{name} ILIKE ?", "%#{self.class.sanitize_sql_like(params)}%")
11
+ scope.where(where_condition, search_term: "%#{self.class.sanitize_sql_like(params)}%")
12
+ end
13
+
14
+ protected
15
+
16
+ def where_condition
17
+ # PostgreSQL handles removing accents if `unaccent` extension is enabled
18
+ if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" && ActiveRecord::Base.connection.extensions.include?('unaccent')
19
+ "unaccent(#{facets.model_table_name}.#{name}) ILIKE unaccent(:search_term)"
20
+ else
21
+ "#{facets.model_table_name}.#{name} ILIKE :search_term"
22
+ end
12
23
  end
13
24
  end
14
25
  end
@@ -53,7 +53,12 @@ module FacetedSearch
53
53
  end
54
54
 
55
55
  def has_params?
56
- params.values.select(&:present?).any?
56
+ any = false
57
+ list.each do |facet|
58
+ next if facet.hide_in_selected?
59
+ any = true if facet.params.present?
60
+ end
61
+ any
57
62
  end
58
63
 
59
64
  protected
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <% facet.values.each do |value| %>
3
4
  <% identifier = value.send facet.find_by %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <% facet.values.each do |year| %>
3
4
  <% if facet.value_selected?(year) %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <%= render 'faceted_search/facets/full_tree/values-selected',
3
4
  values: facet.values_with_parent(nil),
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% values.each do |value| %>
2
3
  <% identifier = value.send facet.find_by %>
3
4
  <% if facet.value_selected?(identifier) %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% values.each do |value| %>
2
3
  <% identifier = value.send facet.find_by %>
3
4
  <li class="faceted__facet__full_tree__value<%= '--selected' if facet.value_selected?(identifier) %> dd-item <%= 'dd-item--selected' if facet.value_selected?(identifier) %>">
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <% facet.values.each do |value| %>
3
4
  <% identifier = value.send facet.find_by %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <li>
2
3
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
3
4
  <%
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% value = params[:facets][facet.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
2
3
  <% unless value.blank? %>
3
4
  <%= render 'faceted_search/facets/facet-selected',
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <li>
2
3
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
3
4
  <% value = params[:facets][facet.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% value = params[:facets][facet.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
2
3
  <% unless value.blank? %>
3
4
  <%= render 'faceted_search/facets/facet-selected',
@@ -1,3 +1,4 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
@@ -1,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.5.7'
2
+ VERSION = '3.5.11'
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faceted_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.7
4
+ version: 3.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
8
8
  - Sébastien Gaya
9
9
  - Sébastien Moulène
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-28 00:00:00.000000000 Z
13
+ date: 2022-04-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -170,7 +170,7 @@ homepage: http://github.com/lespoupeesrusses/faceted_search
170
170
  licenses:
171
171
  - MIT
172
172
  metadata: {}
173
- post_install_message:
173
+ post_install_message:
174
174
  rdoc_options: []
175
175
  require_paths:
176
176
  - lib
@@ -185,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.1.4
189
- signing_key:
188
+ rubygems_version: 3.3.7
189
+ signing_key:
190
190
  specification_version: 4
191
191
  summary: Faceted search with Active Record
192
192
  test_files: []