blacklight-hierarchy 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +13 -9
- data/app/components/blacklight/hierarchy/facet_field_component.html.erb +18 -0
- data/app/components/blacklight/hierarchy/facet_field_component.rb +33 -0
- data/app/components/blacklight/hierarchy/facet_field_list_component.html.erb +12 -0
- data/app/components/blacklight/hierarchy/facet_field_list_component.rb +72 -0
- data/app/components/blacklight/hierarchy/qfacet_value_component.html.erb +1 -0
- data/app/components/blacklight/hierarchy/qfacet_value_component.rb +26 -0
- data/app/components/blacklight/hierarchy/selected_qfacet_value_component.html.erb +4 -0
- data/app/components/blacklight/hierarchy/selected_qfacet_value_component.rb +19 -0
- data/app/helpers/blacklight/hierarchy_helper.rb +24 -4
- data/app/models/hierarchical_facet_item.rb +1 -0
- data/app/views/blacklight/hierarchy/_facet_hierarchy.html.erb +4 -0
- data/blacklight-hierarchy.gemspec +3 -3
- data/lib/blacklight/hierarchy/version.rb +1 -1
- data/spec/features/basic_spec.rb +4 -5
- data/spec/helpers/hierarchy_helper_spec.rb +1 -0
- metadata +16 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c27766d9e3478e114c0c47f20a6d9e117aabd392bdfbe95ced2a1280b80759ee
|
4
|
+
data.tar.gz: 4661be605018474298c69155324327607665e0e0ddd6561ea960a40ffd91cb51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e6ff1475cfdb98679c258e5174ddea50be40324b384b8cf29c6affbc04f66ad2c2fd4ef89368c0979731e878a0af3e31fe889125b9f7786d823e3aeef9d29a6
|
7
|
+
data.tar.gz: 79b0d2b32e5b861f8931d47b73dfb4bf37662954cb6274c34dbb2d9ff6086ac54c88069e5b9c3155e93da8e36572155d7f2fe53c00c7ab91bd69cec59784a702
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -46,18 +46,18 @@ You can skip as many levels as you'd like, as long as the "leaf" values are inde
|
|
46
46
|
|
47
47
|
**Note**: If you use Solr's built-in [PathHierarchyTokenizerFactory](http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.PathHierarchyTokenizerFactory), you can index the entire depth by supplying only the leaf nodes. Otherwise you are expected to build the permutations yourself before loading.
|
48
48
|
|
49
|
-
In your Blacklight controller configuration (usually `CatalogController`), tell Blacklight to render the facet using the hierarchy
|
49
|
+
In your Blacklight controller configuration (usually `CatalogController`), tell Blacklight to render the facet using the hierarchy component.
|
50
50
|
|
51
51
|
|
52
52
|
```ruby
|
53
|
-
config.add_facet_field 'queue_wps', :
|
54
|
-
config.add_facet_field 'queue_wsp', :
|
55
|
-
config.add_facet_field 'queue_swp', :
|
56
|
-
config.add_facet_field 'callnum_top', :
|
57
|
-
config.add_facet_field 'foo_trunk', :
|
58
|
-
config.add_facet_field 'foo_branch', :
|
59
|
-
config.add_facet_field 'foo_leaves', :
|
60
|
-
config.add_facet_field 'tag_facet', :
|
53
|
+
config.add_facet_field 'queue_wps', label: 'Queue Status', component: Blacklight::Hierarchy::FacetFieldListComponent
|
54
|
+
config.add_facet_field 'queue_wsp', label: 'Queue Status', component: Blacklight::Hierarchy::FacetFieldListComponent
|
55
|
+
config.add_facet_field 'queue_swp', label: 'Queue Status', component: Blacklight::Hierarchy::FacetFieldListComponent
|
56
|
+
config.add_facet_field 'callnum_top', label: 'Callnumber', component: Blacklight::Hierarchy::FacetFieldListComponent
|
57
|
+
config.add_facet_field 'foo_trunk', label: 'Foo L1', component: Blacklight::Hierarchy::FacetFieldListComponent
|
58
|
+
config.add_facet_field 'foo_branch', label: 'Foo L2', component: Blacklight::Hierarchy::FacetFieldListComponent
|
59
|
+
config.add_facet_field 'foo_leaves', label: 'Foo L3', component: Blacklight::Hierarchy::FacetFieldListComponent
|
60
|
+
config.add_facet_field 'tag_facet', label: 'Tag', component: Blacklight::Hierarchy::FacetFieldListComponent
|
61
61
|
```
|
62
62
|
|
63
63
|
Add your hierarchy-specific options to the controller configuration:
|
@@ -106,6 +106,10 @@ en:
|
|
106
106
|
toggle_aria_label: Toggle call number section
|
107
107
|
```
|
108
108
|
|
109
|
+
### Javascript
|
110
|
+
|
111
|
+
The javascript in this project requires jquery, but it's up to you to provide it in a way that best works for your project. You may consider the jquery-rails gem or if you use webpacker, you could use the jquery npm package.
|
112
|
+
|
109
113
|
## Caveats
|
110
114
|
|
111
115
|
This code was ripped out of another project, and is still quite immature as a standalone project. Every effort has been made to make it as plug-and-play as possible, but it may stomp on Blacklight in unintended ways (e.g., ways that made sense in context of its former host app, but which aren't compatible with generic Blacklight). Proceed with caution, and report issues.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<li class="<%= li_class %>" role="treeitem">
|
2
|
+
<%= helpers.facet_toggle_button(field_name, id) if subset.any? %>
|
3
|
+
<% if item.nil? %>
|
4
|
+
<%= key %>
|
5
|
+
<% elsif qfacet_selected? %>
|
6
|
+
<%= render Blacklight::Hierarchy::SelectedQfacetValueComponent.new(field_name: field_name, item: item) %>
|
7
|
+
<% else %>
|
8
|
+
<%= render Blacklight::Hierarchy::QfacetValueComponent.new(field_name: field_name, item: item, id: id) %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% unless subset.empty? %>
|
12
|
+
<ul role=\"group\">
|
13
|
+
<% subset.keys.sort.each do |subkey| %>
|
14
|
+
<%= render self.class.new(field_name: field_name, tree: subset[subkey], key: subkey) %>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
<% end %>
|
18
|
+
</li>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
module Hierarchy
|
5
|
+
class FacetFieldComponent < ::ViewComponent::Base
|
6
|
+
def initialize(field_name:, tree:, key:)
|
7
|
+
@field_name = field_name
|
8
|
+
@tree = tree
|
9
|
+
@key = key
|
10
|
+
@id = SecureRandom.uuid
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :field_name, :tree, :key, :id
|
14
|
+
|
15
|
+
def subset
|
16
|
+
@subset ||= tree.reject { |k, _v| !k.is_a?(String) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def li_class
|
20
|
+
subset.empty? ? 'h-leaf' : 'h-node'
|
21
|
+
end
|
22
|
+
|
23
|
+
def item
|
24
|
+
tree[:_]
|
25
|
+
end
|
26
|
+
|
27
|
+
def qfacet_selected?
|
28
|
+
config = helpers.facet_configuration_for_field(field_name)
|
29
|
+
helpers.search_state.has_facet?(config, value: item.qvalue)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<%= render(@layout.new(facet_field: @facet_field)) do |component| %>
|
2
|
+
<% component.with(:label) do %>
|
3
|
+
<%= @facet_field.label %>
|
4
|
+
<% end %>
|
5
|
+
<% component.with(:body) do %>
|
6
|
+
<ul class="facet-hierarchy" role="tree">
|
7
|
+
<% tree.keys.sort.collect do |key| %>
|
8
|
+
<%= render Blacklight::Hierarchy::FacetFieldComponent.new(field_name: @facet_field.facet_field.field, tree: tree[key], key: key) %>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
module Hierarchy
|
5
|
+
class FacetFieldListComponent < Blacklight::FacetFieldListComponent
|
6
|
+
DELIMETER = '_'
|
7
|
+
|
8
|
+
# @param [Blacklight::Configuration::FacetField] as defined in controller with config.add_facet_field (and with :partial => 'blacklight/hierarchy/facet_hierarchy')
|
9
|
+
# @return [String] html for the facet tree
|
10
|
+
def tree
|
11
|
+
@tree ||= begin
|
12
|
+
facet_tree_for_prefix = facet_tree
|
13
|
+
facet_tree_for_prefix ? facet_tree_for_prefix[field_name] : nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def field_name
|
18
|
+
@facet_field.facet_field.field
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] a key to access the rest of the hierarchy tree, as defined in controller config.facet_display[:hierarchy] declaration.
|
22
|
+
# e.g. if you had this in controller:
|
23
|
+
# config.facet_display = {
|
24
|
+
# :hierarchy => {
|
25
|
+
# 'wf' => [['wps','wsp','swp'], ':'],
|
26
|
+
# 'callnum_top' => [['facet'], '/'],
|
27
|
+
# 'exploded_tag' => [['ssim'], ':']
|
28
|
+
# }
|
29
|
+
# }
|
30
|
+
# then possible hkey values would be 'wf', 'callnum_top', and 'exploded_tag'.
|
31
|
+
#
|
32
|
+
# the key in the :hierarchy hash is the "prefix" for the solr field with the hierarchy info. the value
|
33
|
+
# in the hash is a list, where the first element is a list of suffixes, and the second element is the delimiter
|
34
|
+
# used to break up the sections of hierarchical data in the solr field being read. when joined, the prefix and
|
35
|
+
# suffix should form the field name. so, for example, 'wf_wps', 'wf_wsp', 'wf_swp', 'callnum_top_facet', and
|
36
|
+
# 'exploded_tag_ssim' would be the solr fields with blacklight-hierarchy related configuration according to the
|
37
|
+
# hash above. ':' would be the delimiter used in all of those fields except for 'callnum_top_facet', which would
|
38
|
+
# use '/'. exploded_tag_ssim might contain values like ['Book', 'Book : Multi-Volume Work'], and callnum_top_facet
|
39
|
+
# might contain values like ['LB', 'LB/2395', 'LB/2395/.C65', 'LB/2395/.C65/1991'].
|
40
|
+
# note: the suffixes (e.g. 'ssim' for 'exploded_tag' in the above example) can't have underscores, otherwise things break.
|
41
|
+
def prefix
|
42
|
+
@prefix ||= field_name.gsub("#{DELIMETER}#{field_name.split(/#{DELIMETER}/).last}", '')
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
delegate :blacklight_config, to: :helpers
|
47
|
+
|
48
|
+
def facet_tree
|
49
|
+
@facet_tree ||= {}
|
50
|
+
return @facet_tree[prefix] unless @facet_tree[prefix].nil?
|
51
|
+
return @facet_tree[prefix] unless blacklight_config.facet_display[:hierarchy] && blacklight_config.facet_display[:hierarchy][prefix]
|
52
|
+
@facet_tree[prefix] = {}
|
53
|
+
facet_config = blacklight_config.facet_display[:hierarchy][prefix]
|
54
|
+
split_regex = Regexp.new("\s*#{Regexp.escape(facet_config.length >= 2 ? facet_config[1] : ':')}\s*")
|
55
|
+
facet_config.first.each do |key|
|
56
|
+
# TODO: remove baked in notion of underscores being part of the blacklight facet field names
|
57
|
+
facet_field = [prefix, key].compact.join('_')
|
58
|
+
@facet_tree[prefix][facet_field] ||= {}
|
59
|
+
data = @facet_field.display_facet
|
60
|
+
next if data.nil?
|
61
|
+
data.items.each do |facet_item|
|
62
|
+
path = facet_item.value.split(split_regex)
|
63
|
+
loc = @facet_tree[prefix][facet_field]
|
64
|
+
loc = loc[path.shift] ||= {} while path.length > 0
|
65
|
+
loc[:_] = HierarchicalFacetItem.new(facet_item.value, facet_item.value.split(split_regex).last, facet_item.hits)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@facet_tree[prefix]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to_unless suppress_link, item.value, path_for_facet, id: id, class: 'facet_select' %> <%= render_facet_count %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
module Hierarchy
|
5
|
+
class QfacetValueComponent < ::ViewComponent::Base
|
6
|
+
def initialize(field_name:, item:, id: nil, suppress_link: false)
|
7
|
+
@field_name = field_name
|
8
|
+
@item = item
|
9
|
+
@id = id
|
10
|
+
@suppress_link = suppress_link
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :field_name, :item, :id, :suppress_link
|
14
|
+
|
15
|
+
def path_for_facet
|
16
|
+
facet_config = helpers.facet_configuration_for_field(field_name)
|
17
|
+
Blacklight::FacetItemPresenter.new(item.qvalue, facet_config, helpers, field_name).href
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_facet_count
|
21
|
+
classes = "facet-count"
|
22
|
+
content_tag("span", t('blacklight.search.facets.count', number: number_with_delimiter(item.hits)), class: classes)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<span class="selected"><%= render Blacklight::Hierarchy::QfacetValueComponent.new(field_name: field_name, item: item, suppress_link: true) %></span>
|
2
|
+
<%= link_to remove_href, class: 'remove' do %>
|
3
|
+
<span class="glyphicon glyphicon-remove"></span><span class="sr-only">[remove]</span>
|
4
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
module Hierarchy
|
5
|
+
# Standard display of a SELECTED facet value, no link, special span with class, and 'remove' button.
|
6
|
+
class SelectedQfacetValueComponent < ::ViewComponent::Base
|
7
|
+
def initialize(field_name:, item:)
|
8
|
+
@field_name = field_name
|
9
|
+
@item = item
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :field_name, :item
|
13
|
+
|
14
|
+
def remove_href
|
15
|
+
helpers.search_action_path(helpers.search_state.remove_facet_params(field_name, item.qvalue))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'deprecation'
|
2
|
+
|
1
3
|
module Blacklight::HierarchyHelper
|
2
4
|
# Putting bare HTML strings in a helper sucks. But in this case, with a
|
3
5
|
# lot of recursive tree-walking going on, it's an order of magnitude faster
|
@@ -13,7 +15,7 @@ module Blacklight::HierarchyHelper
|
|
13
15
|
li << facet_toggle_button(field_name, id) if subset.any?
|
14
16
|
li << if item.nil?
|
15
17
|
key
|
16
|
-
elsif
|
18
|
+
elsif qfacet_selected?(field_name, item)
|
17
19
|
render_selected_qfacet_value(field_name, item)
|
18
20
|
else
|
19
21
|
render_qfacet_value(field_name, item, id: id)
|
@@ -28,6 +30,13 @@ module Blacklight::HierarchyHelper
|
|
28
30
|
|
29
31
|
%(<li class="#{li_class}" role="treeitem">#{li.html_safe}#{ul.html_safe}</li>).html_safe
|
30
32
|
end
|
33
|
+
deprecation_deprecate :render_facet_hierarchy_item
|
34
|
+
|
35
|
+
def qfacet_selected?(field_name, item)
|
36
|
+
config = facet_configuration_for_field(field_name)
|
37
|
+
search_state.has_facet?(config, value: facet_value_for_facet_item(item.qvalue))
|
38
|
+
end
|
39
|
+
private :qfacet_selected?
|
31
40
|
|
32
41
|
# @param [Blacklight::Configuration::FacetField] as defined in controller with config.add_facet_field (and with :partial => 'blacklight/hierarchy/facet_hierarchy')
|
33
42
|
# @return [String] html for the facet tree
|
@@ -42,11 +51,15 @@ module Blacklight::HierarchyHelper
|
|
42
51
|
render_facet_hierarchy_item(field_name, tree[key], key)
|
43
52
|
end.join("\n").html_safe
|
44
53
|
end
|
54
|
+
deprecation_deprecate :render_hierarchy
|
45
55
|
|
46
56
|
def render_qfacet_value(facet_solr_field, item, options = {})
|
47
57
|
id = options.delete(:id)
|
48
|
-
|
58
|
+
facet_config = facet_configuration_for_field(facet_solr_field)
|
59
|
+
path_for_facet = facet_item_presenter(facet_config, item.qvalue, facet_solr_field).href
|
60
|
+
(link_to_unless(options[:suppress_link], item.value, path_for_facet, id: id, class: 'facet_select') + ' ' + render_facet_count(item.hits)).html_safe
|
49
61
|
end
|
62
|
+
deprecation_deprecate :render_qfacet_value
|
50
63
|
|
51
64
|
# Standard display of a SELECTED facet value, no link, special span with class, and 'remove' button.
|
52
65
|
def render_selected_qfacet_value(facet_solr_field, item)
|
@@ -58,8 +71,7 @@ module Blacklight::HierarchyHelper
|
|
58
71
|
class: 'remove'
|
59
72
|
)
|
60
73
|
end
|
61
|
-
|
62
|
-
HierarchicalFacetItem = Struct.new :qvalue, :value, :hits
|
74
|
+
deprecation_deprecate :render_selected_qfacet_value
|
63
75
|
|
64
76
|
# @param [String] hkey - a key to access the rest of the hierarchy tree, as defined in controller config.facet_display[:hierarchy] declaration.
|
65
77
|
# e.g. if you had this in controller:
|
@@ -103,6 +115,7 @@ module Blacklight::HierarchyHelper
|
|
103
115
|
end
|
104
116
|
@facet_tree[hkey]
|
105
117
|
end
|
118
|
+
deprecation_deprecate :facet_tree
|
106
119
|
|
107
120
|
def facet_toggle_button(field_name, described_by)
|
108
121
|
aria_label = I18n.t(
|
@@ -131,11 +144,13 @@ module Blacklight::HierarchyHelper
|
|
131
144
|
(prefix, order) = field_name.split(/_/, 2)
|
132
145
|
(list = blacklight_config.facet_display[:hierarchy][prefix]) && list.include?(order)
|
133
146
|
end
|
147
|
+
deprecation_deprecate :is_hierarchical?
|
134
148
|
|
135
149
|
def facet_order(prefix)
|
136
150
|
param_name = "#{prefix}_facet_order".to_sym
|
137
151
|
params[param_name] || blacklight_config.facet_display[:hierarchy][prefix].first
|
138
152
|
end
|
153
|
+
deprecation_deprecate :facet_order
|
139
154
|
|
140
155
|
def facet_after(prefix, order)
|
141
156
|
orders = blacklight_config.facet_display[:hierarchy][prefix]
|
@@ -148,6 +163,8 @@ module Blacklight::HierarchyHelper
|
|
148
163
|
prefix = field_name.split(/_/).first
|
149
164
|
field_name != "#{prefix}_#{facet_order(prefix)}"
|
150
165
|
end
|
166
|
+
deprecation_deprecate :hide_facet?
|
167
|
+
|
151
168
|
|
152
169
|
# FIXME: remove baked in colon separator
|
153
170
|
def rotate_facet_value(val, from, to)
|
@@ -157,6 +174,7 @@ module Blacklight::HierarchyHelper
|
|
157
174
|
return nil if new_values.include?(nil)
|
158
175
|
new_values.compact.join(':')
|
159
176
|
end
|
177
|
+
deprecation_deprecate :rotate_facet_value
|
160
178
|
|
161
179
|
# FIXME: remove baked in underscore separator in field name
|
162
180
|
def rotate_facet_params(prefix, from, to, p = params.dup)
|
@@ -172,6 +190,7 @@ module Blacklight::HierarchyHelper
|
|
172
190
|
p[:f].delete(to_field) if p[:f][to_field].empty?
|
173
191
|
p
|
174
192
|
end
|
193
|
+
deprecation_deprecate :rotate_facet_params
|
175
194
|
|
176
195
|
# FIXME: remove baked in underscore separator in field name
|
177
196
|
def render_facet_rotate(field_name)
|
@@ -183,4 +202,5 @@ module Blacklight::HierarchyHelper
|
|
183
202
|
new_params["#{prefix}_facet_order"] = new_order
|
184
203
|
link_to image_tag('icons/rotate.png', title: new_order.upcase).html_safe, new_params, class: 'no-underline'
|
185
204
|
end
|
205
|
+
deprecation_deprecate :render_facet_rotate
|
186
206
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
HierarchicalFacetItem = Struct.new :qvalue, :value, :hits
|
@@ -1,3 +1,7 @@
|
|
1
|
+
<% Deprecation.warn(self, "Calling the blacklight/hierarchy/facet_hierarchy partial is " \
|
2
|
+
"deprecated and will be removed in blacklight-hierarchy 5.0. Replace the facet config for '#{facet_field.key}':\n\n\t" \
|
3
|
+
":partial => 'blacklight/hierarchy/facet_hierarchy'\n\nwith:\n\n\t" \
|
4
|
+
":component => Blacklight::Hierarchy::FacetFieldListComponent\n\n") %>
|
1
5
|
<ul class="facet-hierarchy" role="tree">
|
2
6
|
<%= render_hierarchy(facet_field) %>
|
3
7
|
</ul>
|
@@ -18,10 +18,10 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
#
|
22
|
-
s.add_dependency 'blacklight', '
|
21
|
+
# A version of blacklight with view_component is required
|
22
|
+
s.add_dependency 'blacklight', '~> 7.9'
|
23
23
|
s.add_dependency 'rails', '>= 5.1', '< 7'
|
24
|
-
s.add_dependency '
|
24
|
+
s.add_dependency 'deprecation'
|
25
25
|
|
26
26
|
s.add_development_dependency 'rsolr'
|
27
27
|
s.add_development_dependency 'rspec-rails'
|
data/spec/features/basic_spec.rb
CHANGED
@@ -99,9 +99,8 @@ describe 'config_1' do
|
|
99
99
|
before do
|
100
100
|
CatalogController.blacklight_config = Blacklight::Configuration.new
|
101
101
|
CatalogController.configure_blacklight do |config|
|
102
|
-
|
103
|
-
config.add_facet_field '
|
104
|
-
config.add_facet_field 'my_top_facet', label: 'Slash Delim', partial: 'blacklight/hierarchy/facet_hierarchy'
|
102
|
+
config.add_facet_field 'tag_facet', label: 'Tag', component: Blacklight::Hierarchy::FacetFieldListComponent
|
103
|
+
config.add_facet_field 'my_top_facet', label: 'Slash Delim', component: Blacklight::Hierarchy::FacetFieldListComponent
|
105
104
|
config.facet_display = {
|
106
105
|
hierarchy: {
|
107
106
|
# 'rotate' => [['tag' ], ':'], # this would work if config.add_facet_field was called rotate_tag_facet, instead of tag_facet, I think.
|
@@ -119,8 +118,8 @@ describe 'config_2' do
|
|
119
118
|
before do
|
120
119
|
CatalogController.blacklight_config = Blacklight::Configuration.new
|
121
120
|
CatalogController.configure_blacklight do |config|
|
122
|
-
config.add_facet_field 'tag_facet', label: 'Tag',
|
123
|
-
config.add_facet_field 'my_top_facet', label: 'Slash Delim',
|
121
|
+
config.add_facet_field 'tag_facet', label: 'Tag', component: Blacklight::Hierarchy::FacetFieldListComponent
|
122
|
+
config.add_facet_field 'my_top_facet', label: 'Slash Delim', component: Blacklight::Hierarchy::FacetFieldListComponent
|
124
123
|
config.facet_display = {
|
125
124
|
hierarchy: {
|
126
125
|
'tag' => [['facet']], # rely on default delim
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Blacklight::HierarchyHelper do
|
4
4
|
describe '#render_hierarchy' do
|
5
5
|
it 'should remove the _suffix from the field name' do
|
6
|
+
expect(Deprecation).to receive(:warn)
|
6
7
|
field = OpenStruct.new(field: 'the_field_name_facet')
|
7
8
|
expect(helper).to receive(:facet_tree).with('the_field_name').and_return({})
|
8
9
|
helper.render_hierarchy(field)
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-hierarchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael B. Klein
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.20'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '7.9'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '6.20'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '7.9'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rails
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +45,7 @@ dependencies:
|
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '7'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
48
|
+
name: deprecation
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
51
|
- - ">="
|
@@ -167,7 +161,16 @@ files:
|
|
167
161
|
- Rakefile
|
168
162
|
- app/assets/javascripts/blacklight/hierarchy/hierarchy.js
|
169
163
|
- app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss
|
164
|
+
- app/components/blacklight/hierarchy/facet_field_component.html.erb
|
165
|
+
- app/components/blacklight/hierarchy/facet_field_component.rb
|
166
|
+
- app/components/blacklight/hierarchy/facet_field_list_component.html.erb
|
167
|
+
- app/components/blacklight/hierarchy/facet_field_list_component.rb
|
168
|
+
- app/components/blacklight/hierarchy/qfacet_value_component.html.erb
|
169
|
+
- app/components/blacklight/hierarchy/qfacet_value_component.rb
|
170
|
+
- app/components/blacklight/hierarchy/selected_qfacet_value_component.html.erb
|
171
|
+
- app/components/blacklight/hierarchy/selected_qfacet_value_component.rb
|
170
172
|
- app/helpers/blacklight/hierarchy_helper.rb
|
173
|
+
- app/models/hierarchical_facet_item.rb
|
171
174
|
- app/views/blacklight/hierarchy/_facet_hierarchy.html.erb
|
172
175
|
- blacklight-hierarchy.gemspec
|
173
176
|
- config/locales/blacklight-hierarchy.ar.yml
|