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 +4 -4
- data/app/models/faceted_search/facets.rb +15 -8
- data/app/models/faceted_search/facets/date.rb +11 -5
- data/app/models/faceted_search/facets/default_list.rb +4 -3
- data/app/models/faceted_search/facets/primitive_list.rb +11 -4
- data/app/views/faceted_search/_facets.html.erb +1 -1
- data/app/views/faceted_search/facets/checkboxes/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/checkboxes/_selected.html.erb +2 -1
- data/app/views/faceted_search/facets/date/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/date/_selected.html.erb +2 -1
- data/app/views/faceted_search/facets/full_tree/_all.html.erb +2 -1
- data/app/views/faceted_search/facets/full_tree/_selected.html.erb +3 -1
- data/app/views/faceted_search/facets/full_tree/_values-selected.html.erb +2 -1
- data/app/views/faceted_search/facets/full_tree/_values.html.erb +3 -2
- data/app/views/faceted_search/facets/list/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/list/_selected.html.erb +2 -1
- data/app/views/faceted_search/facets/primitive_list/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/range/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/range/_selected.html.erb +2 -1
- data/app/views/faceted_search/facets/text/_all.html.erb +1 -0
- data/app/views/faceted_search/facets/text/_selected.html.erb +2 -1
- data/app/views/faceted_search/facets/tree/_all.html.erb +3 -2
- data/lib/faceted_search/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4d977f19f2132c5b2bd915b5e31b8994bc3a9cfea14e437abd71335e9ade21d
|
4
|
+
data.tar.gz: ee426d8c2bc8db64d11e00ec0200e292c51fbd7d056267a3389ff4ad44d75f38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
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
|
-
|
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
|
-
@
|
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
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
+
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
|
-
|
26
|
-
|
27
|
-
|
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
|
@@ -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,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,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
|
<% 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,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,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',
|
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
|
+
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-
|
13
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|