faceted_search 3.5.4 → 3.5.10

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: f9c031c6042e6795df7c7465fba26d1ff6e8d8ad3c7f3db94859febdcf3df6e0
4
- data.tar.gz: c534ffb91303aaa601e530bd2271bb36dcef60ec01d04ba97ee74645f8968e86
3
+ metadata.gz: f4d977f19f2132c5b2bd915b5e31b8994bc3a9cfea14e437abd71335e9ade21d
4
+ data.tar.gz: ee426d8c2bc8db64d11e00ec0200e292c51fbd7d056267a3389ff4ad44d75f38
5
5
  SHA512:
6
- metadata.gz: f062d6086f4608816429ad31f69cf706f7a7868e486183a3c42f7c1d546190c8142d8dcc6b2cb3fb91901b0f26f64cf49c848a3c5de37407d7cd9150ab0ca737
7
- data.tar.gz: 90669a44d5ba16929296b22854a80446ddb88cde6ea2df4e38e96495e25ab61b3e7b38788fefce07ce78d5a55162bf11b9cef99106616f6bd9388da228f68b13
6
+ metadata.gz: f73ede5472a4581e99a3a0fa8b54bd65221cc2cc02ab24d12d692ee89570aa20e57dab1849f1f0b59cc3d37b27c7037cb0b4e6d21abc2f7f33f2e0253e29cf3b
7
+ data.tar.gz: c38073518e0da2178cd5a4d7e431fb315a879b8e9446d12eedf80ba4c2318b06aced9541aa8381e073e16058656de81286c6ae638f24f1a532c44436f9121961
@@ -36,14 +36,16 @@ module FacetedSearch
36
36
  end
37
37
 
38
38
  def results
39
- unless @results
40
- scope = @model
41
- list.each do |facet|
42
- scope = facet.add_scope(scope) unless facet.ignore_scope?
43
- end
44
- @results = scope.distinct
39
+ @results ||= results_except []
40
+ end
41
+
42
+ def results_except(*facet_names)
43
+ scope = @model
44
+ list.each do |facet|
45
+ next if facet_names.include?(facet.name) || facet.ignore_scope?
46
+ scope = facet.add_scope(scope)
45
47
  end
46
- @results
48
+ scope.distinct
47
49
  end
48
50
 
49
51
  def model_table_name
@@ -51,7 +53,12 @@ module FacetedSearch
51
53
  end
52
54
 
53
55
  def has_params?
54
- 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
55
62
  end
56
63
 
57
64
  protected
@@ -2,7 +2,14 @@ module FacetedSearch
2
2
  class Facets::Date < Facets::DefaultList
3
3
 
4
4
  def source
5
- @options[:source] || @facets.model.send(:all).pluck(name).compact.map(&:year).uniq.sort
5
+ @source ||= begin
6
+ if @options[:source].present?
7
+ @options[:source]
8
+ else
9
+ results = params_array.blank? ? facets.results : facets.results_except(@name)
10
+ results.send(:all).pluck(name).compact.map(&:year).uniq.sort
11
+ end
12
+ end
6
13
  end
7
14
 
8
15
  def order
@@ -19,11 +26,10 @@ module FacetedSearch
19
26
  end
20
27
 
21
28
  def values
22
- unless @values
23
- @values = source
24
- @values.reverse! unless order == :asc
29
+ @values ||= begin
30
+ values = (source | params_array.map(&:to_i)).sort
31
+ order == :asc ? values : values.reverse
25
32
  end
26
- @values
27
33
  end
28
34
  end
29
35
  end
@@ -26,11 +26,12 @@ module FacetedSearch
26
26
  # Show all values that have corresponding results with the current params.
27
27
  # This is a regular SQL inner join.
28
28
  def values
29
- unless @values
29
+ @values ||= begin
30
30
  joined_table = facets.model_table_name.to_sym
31
- @values = source.all.joins(joined_table).where(joined_table => { id: facets.results }).distinct
31
+ results = params_array.blank? ? facets.results : facets.results_except(@name)
32
+ values = source.all.joins(joined_table)
33
+ values.where(joined_table => { id: results }).or(values.where(id: params_array)).distinct
32
34
  end
33
- @values
34
35
  end
35
36
 
36
37
  def value_selected?(value)
@@ -2,6 +2,14 @@ module FacetedSearch
2
2
  class Facets::PrimitiveList < Facets::DefaultList
3
3
 
4
4
  def source
5
+ @source ||= begin
6
+ if @options[:source].present?
7
+ @options[:source]
8
+ else
9
+ results = params_array.compact.blank? ? facets.results : facets.results_except(@name)
10
+ results.send(:all).where("#{field} IS NOT NULL")
11
+ end
12
+ end
5
13
  @options[:source].where("#{field} IS NOT NULL")
6
14
  end
7
15
 
@@ -22,11 +30,10 @@ module FacetedSearch
22
30
  end
23
31
 
24
32
  def values
25
- unless @values
26
- @values = source.pluck(field).uniq.reject(&:empty?).sort
27
- @values.reverse! unless order == :asc
33
+ @values ||= begin
34
+ values = (source.pluck(field).uniq.reject(&:blank?) | params_array.compact).sort
35
+ order == :asc ? values : values.reverse
28
36
  end
29
- @values
30
37
  end
31
38
  end
32
39
  end
@@ -10,7 +10,7 @@ reset ||= 'Reset'
10
10
  next if facet.hide_in_selected?
11
11
  partial = "#{facet.kind.underscore}/selected"
12
12
  %>
13
- <%= render partial, facet: facet %>
13
+ <%= render partial, facet: facet, anchor: anchor %>
14
14
  <% end %>
15
15
  </ul>
16
16
  <% end %>
@@ -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 %>
@@ -6,7 +7,7 @@
6
7
  <%= render 'faceted_search/facets/facet-selected',
7
8
  title: facet.title,
8
9
  value: display_value,
9
- path: facet.facets.path_for(facet, identifier) %>
10
+ path: facet.facets.path_for(facet, identifier) + anchor %>
10
11
  <% end %>
11
12
  <% end %>
12
13
  <% end %>
@@ -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,10 +1,11 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <% facet.values.each do |year| %>
3
4
  <% if facet.value_selected?(year) %>
4
5
  <%= render 'faceted_search/facets/facet-selected',
5
6
  title: facet.title,
6
7
  value: year,
7
- path: facet.facets.path_for(facet, year) %>
8
+ path: facet.facets.path_for(facet, year) + anchor %>
8
9
  <% end %>
9
10
  <% end %>
10
11
  <% end %>
@@ -1,10 +1,11 @@
1
+ <% anchor ||= '' %>
1
2
  <% if facet.values.any? %>
2
3
  <li>
3
4
  <% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
4
5
  <div class="static-nestable-list">
5
6
  <div class="dd">
6
7
  <ol class="faceted__facet__full_tree list-unstyled dd-list">
7
- <%= render 'faceted_search/facets/full_tree/values', values: facet.values_with_parent(nil), facet: facet %>
8
+ <%= render 'faceted_search/facets/full_tree/values', values: facet.values_with_parent(nil), facet: facet, anchor: anchor %>
8
9
  </ol>
9
10
  </div>
10
11
  </div>
@@ -1,5 +1,7 @@
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),
4
- facet: facet %>
5
+ facet: facet,
6
+ anchor: anchor %>
5
7
  <% end %>
@@ -1,10 +1,11 @@
1
+ <% anchor ||= '' %>
1
2
  <% values.each do |value| %>
2
3
  <% identifier = value.send facet.find_by %>
3
4
  <% if facet.value_selected?(identifier) %>
4
5
  <%= render 'faceted_search/facets/facet-selected',
5
6
  title: facet.title,
6
7
  value: facet.display_method.call(value),
7
- path: facet.facets.path_for(facet, identifier) %>
8
+ path: facet.facets.path_for(facet, identifier) + anchor %>
8
9
  <% end %>
9
10
  <% child_values = facet.values_with_parent(value.id) %>
10
11
  <% if child_values.any? %>
@@ -1,14 +1,15 @@
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) %>">
4
5
  <%= render 'faceted_search/link',
5
6
  display_value: facet.display_method.call(value),
6
- path: facet.facets.path_for(facet, identifier),
7
+ path: facet.facets.path_for(facet, identifier) + anchor,
7
8
  searchable: facet.searchable %>
8
9
  <% child_values = facet.values_with_parent(value.id) %>
9
10
  <% if child_values.any? %>
10
11
  <ol class="dd-list">
11
- <%= render 'faceted_search/facets/full_tree/values', values: child_values, facet: facet %>
12
+ <%= render 'faceted_search/facets/full_tree/values', values: child_values, facet: facet, anchor: anchor %>
12
13
  </ol>
13
14
  <% end %>
14
15
  </li>
@@ -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 %>
@@ -6,7 +7,7 @@
6
7
  <%= render 'faceted_search/facets/facet-selected',
7
8
  title: facet.title,
8
9
  value: display_value,
9
- path: facet.facets.path_for(facet, identifier) %>
10
+ path: facet.facets.path_for(facet, identifier) + anchor %>
10
11
  <% end %>
11
12
  <% end %>
12
13
  <% end %>
@@ -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,7 +1,8 @@
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',
4
5
  title: facet.title,
5
6
  value: value,
6
- path: facet.facets.path_for(facet, nil) %>
7
+ path: facet.facets.path_for(facet, nil) + anchor %>
7
8
  <% end %>
@@ -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,7 +1,8 @@
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',
4
5
  title: facet.title,
5
6
  value: value,
6
- path: facet.facets.path_for(facet, nil) %>
7
+ path: facet.facets.path_for(facet, nil) + anchor %>
7
8
  <% end %>
@@ -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 %>
@@ -6,7 +7,7 @@
6
7
  <%
7
8
  display_value = facet.display_method.call(facet.selected_object)
8
9
  identifier = facet.selected_object.send facet.find_by
9
- path = facet.facets.path_for(facet, identifier)
10
+ path = facet.facets.path_for(facet, identifier) + anchor
10
11
  %>
11
12
  <div class="faceted__facet__tree__back">
12
13
  <%= link_to path, rel: 'nofollow' do %>
@@ -20,7 +21,7 @@
20
21
  <%
21
22
  display_value = facet.display_method.call(value)
22
23
  identifier = value.send facet.find_by
23
- path = facet.facets.path_for(facet, identifier)
24
+ path = facet.facets.path_for(facet, identifier) + anchor
24
25
  %>
25
26
  <li class="faceted__facet__tree__value">
26
27
  <%= render 'faceted_search/link',
@@ -1,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.5.4'
2
+ VERSION = '3.5.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faceted_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.4
4
+ version: 3.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-28 00:00:00.000000000 Z
13
+ date: 2021-06-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails