faceted_search 3.0.6 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f00683190fb978c192c5688ba87bd5434b1153d30daa2e97d37c008017321166
4
- data.tar.gz: 56e0f73cc1f2e0fe3ae074877b64de6408a06ef78420f6953bd4c8b99dcfdd59
3
+ metadata.gz: fba3eb583446e16d41d10394bdfce26f8ba0737e17f009756ba9588f702c2888
4
+ data.tar.gz: c0620ca3b64d7aaa40c07aac0a95ebcf133673e50616601a43e7689f2a0d66cd
5
5
  SHA512:
6
- metadata.gz: 2ec5d568a256317a881ba0db80431799b941ecaf4d3d5c04a62dfd94ced00f372726074c55e4b4fae88272acec2e323a224346a16e987cdfa5b70573da7de656
7
- data.tar.gz: 54c24998826728ee99fd8fe63216b7c06d74909204a439e5fe91391d4d11169fa97fc049e052683813e59e6973c5d83dd5759a2307494d1a2b1861d41629a19e
6
+ metadata.gz: 35ef9e7e9fe73eba37d5878c54fcdc2f1a3a307433a1f5d1ce4b54cbed02efc3617ce3ff56c80601012a0b1dd7dd5f1561e27933d364c3500a3a14c8d42995d8
7
+ data.tar.gz: 77f001b3b318ffd5f85b1e00634f92c2194d0c9dcfeb1d0986c829f4b8a5c9ea9a55b196e2b1d79b998d1bbac1c817ed21a62b382072a16e3bad2193a5fe613a
@@ -23,6 +23,16 @@ module FacetedSearch
23
23
  : scope.where(name => params_array)
24
24
  end
25
25
 
26
+ # Show all values that have corresponding results with the current params.
27
+ # This is a regular SQL inner join.
28
+ def values
29
+ unless @values
30
+ joined_table = facets.model_table_name.to_sym
31
+ @values = source.all.joins(joined_table).where(joined_table => { id: facets.model }).distinct
32
+ end
33
+ @values
34
+ end
35
+
26
36
  def value_selected?(value)
27
37
  value.to_s.in? params_array
28
38
  end
@@ -1,22 +1,7 @@
1
1
  module FacetedSearch
2
2
  class Facets::FullTree < Facets::DefaultList
3
- def children_scope
4
- @options[:children_scope] ||= Proc.new { |children| children }
5
- end
6
-
7
- def child_values(value)
8
- filtered children_scope.call(value.children)
9
- end
10
-
11
- def values
12
- filtered source.root
13
- end
14
-
15
- protected
16
-
17
- def filtered(list)
18
- joined_table = facets.model_table_name.to_sym
19
- list.joins(joined_table).where(joined_table => { id: facets.results }).distinct
3
+ def values_with_parent(parent_id)
4
+ values.where(parent_id: parent_id)
20
5
  end
21
6
  end
22
7
  end
@@ -1,14 +1,5 @@
1
1
  module FacetedSearch
2
2
  class Facets::List < Facets::DefaultList
3
3
 
4
- # Show all values that have corresponding results with the current params.
5
- # This is a regular SQL inner join.
6
- def values
7
- unless @values
8
- joined_table = facets.model_table_name.to_sym
9
- @values = source.all.joins(joined_table).where(joined_table => { id: facets.model }).distinct
10
- end
11
- @values
12
- end
13
4
  end
14
5
  end
@@ -4,7 +4,7 @@
4
4
  <div class="static-nestable-list">
5
5
  <div class="dd">
6
6
  <ol class="faceted__facet__full_tree list-unstyled dd-list">
7
- <%= render 'faceted_search/facets/full_tree/values', values: facet.values, facet: facet %>
7
+ <%= render 'faceted_search/facets/full_tree/values', values: facet.values_with_parent(nil), facet: facet %>
8
8
  </ol>
9
9
  </div>
10
10
  </div>
@@ -6,7 +6,7 @@
6
6
  %>
7
7
  <li class="faceted__facet__full_tree__value<%= '--selected' if facet.value_selected?(identifier) %> dd-item <%= 'dd-item--selected' if facet.value_selected?(identifier) %>">
8
8
  <%= link_to display_value, path %>
9
- <% child_values = facet.child_values(value) %>
9
+ <% child_values = facet.values_with_parent(value.id) %>
10
10
  <% if child_values.any? %>
11
11
  <ol class="dd-list">
12
12
  <%= render 'faceted_search/facets/full_tree/values', values: child_values, facet: facet %>
@@ -1,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.0.6'
2
+ VERSION = '3.1.0'
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.0.6
4
+ version: 3.1.0
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: 2019-04-24 00:00:00.000000000 Z
13
+ date: 2019-04-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails