faceted_search 3.5.14 → 3.5.16
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/date.rb +1 -1
- data/app/models/faceted_search/facets/default.rb +5 -1
- data/app/models/faceted_search/facets/default_list.rb +1 -1
- data/app/models/faceted_search/facets/primitive_list.rb +1 -1
- data/app/models/faceted_search/facets.rb +6 -5
- data/app/views/faceted_search/_facets.html.erb +8 -6
- data/app/views/faceted_search/facets/range/_all.html.erb +3 -3
- data/app/views/faceted_search/facets/range/_selected.html.erb +1 -1
- data/app/views/faceted_search/facets/text/_all.html.erb +3 -3
- data/app/views/faceted_search/facets/text/_selected.html.erb +1 -1
- data/lib/faceted_search/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cd10cd89d2ea082ea27d55ffdc5063487d03c9682cf7bfcb05b1609244738fc
|
4
|
+
data.tar.gz: adf343649365ab7d49c763362db083dc4d9a5420b793c41e12d061fc58fc8eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e207f0b79d30adea678c56fe99d5b337b9d0f8c73043dd809ed7ad20187dbacd2073155579bff89915be5bb1d2dd57c9547a3dfe7e588c74e27c0b109e70bab
|
7
|
+
data.tar.gz: 802f00e9a008d836e5cd341d524aedc23e67fe6f31fa92574da40b663484529f723eb94e2f81c2d23e17361e81835f55c5955ed60d669959d7e0d962dffbb213
|
@@ -6,7 +6,7 @@ module FacetedSearch
|
|
6
6
|
if @options[:source].present?
|
7
7
|
@options[:source]
|
8
8
|
else
|
9
|
-
results = params_array.blank? ? facets.results : facets.results_except(
|
9
|
+
results = params_array.blank? ? facets.results : facets.results_except(param_name)
|
10
10
|
results.send(:all).pluck(name).compact.map(&:year).uniq.sort
|
11
11
|
end
|
12
12
|
end
|
@@ -33,6 +33,10 @@ module FacetedSearch
|
|
33
33
|
@options[:hide_in_selected] || path_pattern?
|
34
34
|
end
|
35
35
|
|
36
|
+
def param_name
|
37
|
+
@options[:param_name] || name
|
38
|
+
end
|
39
|
+
|
36
40
|
def kind
|
37
41
|
self.class.to_s
|
38
42
|
end
|
@@ -48,7 +52,7 @@ module FacetedSearch
|
|
48
52
|
|
49
53
|
def path(custom_params = @params)
|
50
54
|
return '' if custom_params.blank?
|
51
|
-
"&facets[#{
|
55
|
+
"&facets[#{param_name}]=#{custom_params}"
|
52
56
|
end
|
53
57
|
|
54
58
|
def to_s
|
@@ -28,7 +28,7 @@ module FacetedSearch
|
|
28
28
|
def values
|
29
29
|
@values ||= begin
|
30
30
|
joined_table = facets.model_table_name.to_sym
|
31
|
-
results = params_array.blank? ? facets.results : facets.results_except(
|
31
|
+
results = params_array.blank? ? facets.results : facets.results_except(param_name)
|
32
32
|
values = source.all.joins(joined_table)
|
33
33
|
values.where(joined_table => { id: results }).or(values.where(id: params_array)).distinct
|
34
34
|
end
|
@@ -6,7 +6,7 @@ module FacetedSearch
|
|
6
6
|
if @options[:source].present?
|
7
7
|
@options[:source].where("#{field} IS NOT NULL")
|
8
8
|
else
|
9
|
-
results = params_array.compact.blank? ? facets.results : facets.results_except(
|
9
|
+
results = params_array.compact.blank? ? facets.results : facets.results_except(param_name)
|
10
10
|
results.send(:all).where("#{field} IS NOT NULL")
|
11
11
|
end
|
12
12
|
end
|
@@ -39,10 +39,10 @@ module FacetedSearch
|
|
39
39
|
@results ||= results_except []
|
40
40
|
end
|
41
41
|
|
42
|
-
def results_except(*
|
42
|
+
def results_except(*facet_param_names)
|
43
43
|
scope = @model
|
44
44
|
list.each do |facet|
|
45
|
-
next if
|
45
|
+
next if facet_param_names.include?(facet.param_name) || facet.ignore_scope?
|
46
46
|
scope = facet.add_scope(scope)
|
47
47
|
end
|
48
48
|
scope.distinct
|
@@ -95,12 +95,13 @@ module FacetedSearch
|
|
95
95
|
add_facet Range, value, options
|
96
96
|
end
|
97
97
|
|
98
|
-
def params_for(value)
|
99
|
-
|
98
|
+
def params_for(value, options)
|
99
|
+
param_name = (options[:param_name] || value).to_sym
|
100
|
+
@params[param_name] if @params.has_key? param_name
|
100
101
|
end
|
101
102
|
|
102
103
|
def add_facet(kind, value, options)
|
103
|
-
@list << kind.new(value, params_for(value), self, options)
|
104
|
+
@list << kind.new(value, params_for(value, options), self, options)
|
104
105
|
end
|
105
106
|
end
|
106
107
|
end
|
@@ -20,10 +20,12 @@ reset ||= 'Reset'
|
|
20
20
|
<% partial = "#{facet.kind.underscore}/all" %>
|
21
21
|
<%= render partial, facet: facet, anchor: anchor %>
|
22
22
|
<% end %>
|
23
|
-
|
24
|
-
<
|
25
|
-
<
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
<% if facets.has_params? %>
|
24
|
+
<li class="faceted__facet__reinit">
|
25
|
+
<a href="<%= facets.path %>" rel="nofollow">
|
26
|
+
<i class="fas fa-ban"></i>
|
27
|
+
<%= reset %>
|
28
|
+
</a>
|
29
|
+
</li>
|
30
|
+
<% end %>
|
29
31
|
</ul>
|
@@ -2,18 +2,18 @@
|
|
2
2
|
<li>
|
3
3
|
<% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
|
4
4
|
<%
|
5
|
-
value = params[:facets][facet.
|
5
|
+
value = params[:facets][facet.param_name] if params.dig(:facets, facet.param_name).present?
|
6
6
|
value ||= facet.default_value
|
7
7
|
%>
|
8
8
|
<form action="<%= anchor %>" class="faceted__facet__text form-inline">
|
9
9
|
<% facet.facets.list.each do |f| %>
|
10
10
|
<% next if f == facet || f.params.blank? || f.path_pattern? %>
|
11
11
|
<input type="hidden"
|
12
|
-
name="facets[<%= f.
|
12
|
+
name="facets[<%= f.param_name %>]"
|
13
13
|
value="<%= f.params %>" />
|
14
14
|
<% end %>
|
15
15
|
<input type="range"
|
16
|
-
name="facets[<%= facet.
|
16
|
+
name="facets[<%= facet.param_name %>]"
|
17
17
|
min="<%= facet.min %>"
|
18
18
|
max="<%= facet.max %>"
|
19
19
|
step="<%= facet.step %>"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% anchor ||= '' %>
|
2
|
-
<% value = params[:facets][facet.
|
2
|
+
<% value = params[:facets][facet.param_name] if params[:facets] && params[:facets].has_key?(facet.param_name) %>
|
3
3
|
<% unless value.blank? %>
|
4
4
|
<%= render 'faceted_search/facets/facet-selected',
|
5
5
|
title: facet.title,
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<% anchor ||= '' %>
|
2
2
|
<li>
|
3
3
|
<% unless facet.title.blank? %><b><%= facet.title %></b><% end %>
|
4
|
-
<% value = params[:facets][facet.
|
4
|
+
<% value = params[:facets][facet.param_name] if params[:facets] && params[:facets].has_key?(facet.param_name) %>
|
5
5
|
<form action="<%= anchor %>" class="faceted__facet__text form-inline">
|
6
6
|
<% facet.facets.list.each do |f| %>
|
7
7
|
<% next if f == facet || f.params.blank? || f.path_pattern? %>
|
8
8
|
<input type="hidden"
|
9
|
-
name="facets[<%= f.
|
9
|
+
name="facets[<%= f.param_name %>]"
|
10
10
|
value="<%= f.params %>" />
|
11
11
|
<% end %>
|
12
12
|
<input type="search"
|
13
|
-
name="facets[<%= facet.
|
13
|
+
name="facets[<%= facet.param_name %>]"
|
14
14
|
placeholder="<%= facet.placeholder %>"
|
15
15
|
value="<%= value %>"
|
16
16
|
class="form-control" />
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% anchor ||= '' %>
|
2
|
-
<% value = params[:facets][facet.
|
2
|
+
<% value = params[:facets][facet.param_name] if params[:facets] && params[:facets].has_key?(facet.param_name) %>
|
3
3
|
<% unless value.blank? %>
|
4
4
|
<%= render 'faceted_search/facets/facet-selected',
|
5
5
|
title: facet.title,
|
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.16
|
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: 2022-
|
13
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
|
-
rubygems_version: 3.
|
182
|
+
rubygems_version: 3.3.7
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Faceted search with Active Record
|