faceted_search 3.5.14 → 3.5.15

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: 520ee5f81cdb24604ce3fd089e7dae9bc2314be94af1ec6680752f7f34b65a70
4
- data.tar.gz: 685e1ab85a7642f65229fedb80b8af52c40eac12b29ade22f752e2d71cc3ba89
3
+ metadata.gz: 118ee09dcce76e63a448bfeace430cd56bc9c9f80afa92c252590f133085f04c
4
+ data.tar.gz: 571935067534cf0ad244dd66d250b8adf7e9d038bd3c35d3b8746d661e677210
5
5
  SHA512:
6
- metadata.gz: c116e4a7e83f6806483f9f30b4524123173d7dffd70be045f5f8ce5930c280dc1889544307559b7e10617860798f577052d4017bb4a336e6d23710e6e476da2d
7
- data.tar.gz: 32bfd0603e52e9e93f7ceadcb49e1ed5dc29c9ebf6986fd9e39f7afe8f005dff5ef5960595ce69f4ed3e351961663e8ab9aecfa7c43cca44232b1fa0df09824d
6
+ metadata.gz: 3ad23f4aa1e796de72646961794ea8d1c63a64fcd4ec0333710dd1277aec2af316bc62dbd58ea84eb24dd5857d5a661b01c69af310c39bd8c95786a52eeabf0e
7
+ data.tar.gz: 67ee216d08726b5966073ac33549ed89c4d47433df205a5e56a33a3137dd175a3e1f852b58b6e660527ede3833eb25b677ce4353c94a7a5117026120713ee032
@@ -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(@name)
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[#{name}]=#{custom_params}"
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(@name)
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(@name)
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(*facet_names)
42
+ def results_except(*facet_param_names)
43
43
  scope = @model
44
44
  list.each do |facet|
45
- next if facet_names.include?(facet.name) || facet.ignore_scope?
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
- @params[value] if @params.has_key? value
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
@@ -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.name] if params.dig(:facets, facet.name).present?
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.name %>]"
12
+ name="facets[<%= f.param_name %>]"
13
13
  value="<%= f.params %>" />
14
14
  <% end %>
15
15
  <input type="range"
16
- name="facets[<%= facet.name %>]"
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.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
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.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
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.name %>]"
9
+ name="facets[<%= f.param_name %>]"
10
10
  value="<%= f.params %>" />
11
11
  <% end %>
12
12
  <input type="search"
13
- name="facets[<%= facet.name %>]"
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.name] if params[:facets] && params[:facets].has_key?(facet.name) %>
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,3 +1,3 @@
1
1
  module FacetedSearch
2
- VERSION = '3.5.14'
2
+ VERSION = '3.5.15'
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.14
4
+ version: 3.5.15
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-07-08 00:00:00.000000000 Z
13
+ date: 2022-07-18 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.1.6
182
+ rubygems_version: 3.3.7
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Faceted search with Active Record