faceted_search 3.5.16 → 3.6.1
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 +4 -4
- data/README.md +1 -0
- data/app/models/faceted_search/facets/boolean.rb +14 -0
- data/app/models/faceted_search/facets/default_list.rb +29 -9
- data/app/models/faceted_search/facets.rb +4 -0
- data/app/views/faceted_search/facets/boolean/_all.html.erb +15 -0
- data/app/views/faceted_search/facets/boolean/_selected.html.erb +8 -0
- data/lib/faceted_search/version.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf6eb515ded15419dfe734adabf061401175de3e53282913e3fed8d34925bed0
|
|
4
|
+
data.tar.gz: '0668e4c8c20ece2f177cf517dadb120f3662dafaa66948f2c311a903f6ff8983'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 889bac63c9c66f13e3f17a811a2468a53511b7626bb69b8872bae1582ff5a3cde8d7c96c41e2bb3d2a09be3452b08a0562faeadd6173dbf41c6a8fbc5472c228
|
|
7
|
+
data.tar.gz: 9f0519609d363702df936afe08ead0603257ecdd63466cd970f54eeb895455728416f31884341f8dc69c7e3f5059abe29ae2bdf975383102191ffaaeca18f9e8
|
data/README.md
CHANGED
|
@@ -18,20 +18,15 @@ module FacetedSearch
|
|
|
18
18
|
# and return the modified scope
|
|
19
19
|
def add_scope(scope)
|
|
20
20
|
return scope if params_array.blank?
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
: scope.where(name => params_array)
|
|
21
|
+
habtm? ? add_scope_with_habtm_true(scope)
|
|
22
|
+
: add_scope_with_habtm_false(scope)
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
# Show all values that have corresponding results with the current params.
|
|
27
26
|
# This is a regular SQL inner join.
|
|
28
27
|
def values
|
|
29
|
-
@values ||=
|
|
30
|
-
|
|
31
|
-
results = params_array.blank? ? facets.results : facets.results_except(param_name)
|
|
32
|
-
values = source.all.joins(joined_table)
|
|
33
|
-
values.where(joined_table => { id: results }).or(values.where(id: params_array)).distinct
|
|
34
|
-
end
|
|
28
|
+
@values ||= habtm? ? values_with_habtm_true
|
|
29
|
+
: values_with_habtm_false
|
|
35
30
|
end
|
|
36
31
|
|
|
37
32
|
def value_selected?(value)
|
|
@@ -48,6 +43,31 @@ module FacetedSearch
|
|
|
48
43
|
|
|
49
44
|
protected
|
|
50
45
|
|
|
46
|
+
def add_scope_with_habtm_true(scope)
|
|
47
|
+
scope.joins(name).where(name => { find_by => params_array })
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def add_scope_with_habtm_false(scope)
|
|
51
|
+
scope.where(name => params_array)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def results
|
|
55
|
+
params_array.blank? ? facets.results : facets.results_except(param_name)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def values_with_habtm_true
|
|
59
|
+
joined_table = facets.model_table_name.to_sym
|
|
60
|
+
values = source.all.joins(joined_table)
|
|
61
|
+
values.where(joined_table => { id: results }).or(values.where(id: params_array)).distinct
|
|
62
|
+
rescue
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def values_with_habtm_false
|
|
66
|
+
property = "#{name}_id"
|
|
67
|
+
ids = results.pluck property
|
|
68
|
+
source.where(id: ids)
|
|
69
|
+
end
|
|
70
|
+
|
|
51
71
|
def params_array
|
|
52
72
|
@params_array ||= @params.to_s.split(',')
|
|
53
73
|
end
|
|
@@ -95,6 +95,10 @@ module FacetedSearch
|
|
|
95
95
|
add_facet Range, value, options
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
def filter_with_boolean(value, options = {})
|
|
99
|
+
add_facet Boolean, value, options
|
|
100
|
+
end
|
|
101
|
+
|
|
98
102
|
def params_for(value, options)
|
|
99
103
|
param_name = (options[:param_name] || value).to_sym
|
|
100
104
|
@params[param_name] if @params.has_key? param_name
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%
|
|
2
|
+
anchor ||= ''
|
|
3
|
+
selected = facet.selected?
|
|
4
|
+
target = !selected
|
|
5
|
+
path = facet.facets.path_for(facet, target) + anchor
|
|
6
|
+
%>
|
|
7
|
+
<li>
|
|
8
|
+
<label>
|
|
9
|
+
<input type="checkbox"
|
|
10
|
+
onclick="window.location.href='<%= path %>'"
|
|
11
|
+
<%= 'checked' if facet.selected? %>
|
|
12
|
+
/>
|
|
13
|
+
<%= facet.title %>
|
|
14
|
+
</label>
|
|
15
|
+
</li>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<% anchor ||= '' %>
|
|
2
|
+
<% value = params[:facets][facet.param_name] if params[:facets] && params[:facets].has_key?(facet.param_name) %>
|
|
3
|
+
<% unless value.blank? %>
|
|
4
|
+
<%= render 'faceted_search/facets/facet-selected',
|
|
5
|
+
title: facet.title,
|
|
6
|
+
value: facet.title,
|
|
7
|
+
path: facet.facets.path_for(facet, nil) + anchor %>
|
|
8
|
+
<% 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.
|
|
4
|
+
version: 3.6.1
|
|
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:
|
|
13
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rails
|
|
@@ -112,7 +112,7 @@ dependencies:
|
|
|
112
112
|
version: '0'
|
|
113
113
|
description: All you need to create a faceted search, as simple as possible
|
|
114
114
|
email:
|
|
115
|
-
-
|
|
115
|
+
- arnaud.levy@noesya.coop
|
|
116
116
|
- sebastien.gaya@gmail.com
|
|
117
117
|
- sebousan@gmail.com
|
|
118
118
|
executables: []
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- Rakefile
|
|
125
125
|
- app/assets/stylesheets/faceted_search.sass
|
|
126
126
|
- app/models/faceted_search/facets.rb
|
|
127
|
+
- app/models/faceted_search/facets/boolean.rb
|
|
127
128
|
- app/models/faceted_search/facets/checkboxes.rb
|
|
128
129
|
- app/models/faceted_search/facets/date.rb
|
|
129
130
|
- app/models/faceted_search/facets/default.rb
|
|
@@ -137,6 +138,8 @@ files:
|
|
|
137
138
|
- app/views/faceted_search/_facets.html.erb
|
|
138
139
|
- app/views/faceted_search/_link.html.erb
|
|
139
140
|
- app/views/faceted_search/facets/_facet-selected.html.erb
|
|
141
|
+
- app/views/faceted_search/facets/boolean/_all.html.erb
|
|
142
|
+
- app/views/faceted_search/facets/boolean/_selected.html.erb
|
|
140
143
|
- app/views/faceted_search/facets/checkboxes/_all.html.erb
|
|
141
144
|
- app/views/faceted_search/facets/checkboxes/_selected.html.erb
|
|
142
145
|
- app/views/faceted_search/facets/date/_all.html.erb
|
|
@@ -160,7 +163,7 @@ files:
|
|
|
160
163
|
- lib/faceted_search/railtie.rb
|
|
161
164
|
- lib/faceted_search/version.rb
|
|
162
165
|
- lib/tasks/faceted_search_tasks.rake
|
|
163
|
-
homepage: http://github.com/
|
|
166
|
+
homepage: http://github.com/noesya/faceted_search
|
|
164
167
|
licenses:
|
|
165
168
|
- MIT
|
|
166
169
|
metadata: {}
|
|
@@ -179,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
182
|
- !ruby/object:Gem::Version
|
|
180
183
|
version: '0'
|
|
181
184
|
requirements: []
|
|
182
|
-
rubygems_version: 3.
|
|
185
|
+
rubygems_version: 3.4.6
|
|
183
186
|
signing_key:
|
|
184
187
|
specification_version: 4
|
|
185
188
|
summary: Faceted search with Active Record
|