blacklight-hierarchy 6.4.0 → 6.6.0
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/.github/workflows/ruby.yml +11 -11
- data/README.md +7 -4
- data/app/assets/javascripts/blacklight/hierarchy/hierarchy.js +24 -24
- data/app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss +1 -0
- data/app/components/blacklight/hierarchy/facet_field_list_component.rb +2 -1
- data/app/models/blacklight/hierarchy/facet_tree.rb +2 -0
- data/blacklight-hierarchy.gemspec +1 -1
- data/lib/blacklight/hierarchy/version.rb +1 -1
- data/package.json +1 -2
- data/spec/models/blacklight/hierarchy/facet_tree_spec.rb +57 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 653bcfc6322d881f68b3e497d01f83bae1e50a180734511849d5f3e34abc1cde
|
4
|
+
data.tar.gz: eca2782a3f9e8e1573ac4d8ce551bef7c8342e7bc9531d4a75a18da558c180df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 761b1a427e8ceb7e8839898322469c8d54418308b8d193511570312c7427e6f6e7d15ef4b8afdf78d2bd8b023fc520d4e4204521f7b58988d0a654792d6930c5
|
7
|
+
data.tar.gz: a8b501673443997fa510da6a5cc68b3b62832fa514bd39396498df3b203a45fab11c5bccbbf5df7db6c510ddf1eb6a31cc1c49907a8e2219e58b6e79e4e45ab8
|
data/.github/workflows/ruby.yml
CHANGED
@@ -18,18 +18,20 @@ jobs:
|
|
18
18
|
runs-on: ubuntu-latest
|
19
19
|
strategy:
|
20
20
|
matrix:
|
21
|
-
ruby: ["3.
|
22
|
-
rails_version: ["7.
|
23
|
-
blacklight_version: ["
|
21
|
+
ruby: ["3.3", "3.4"]
|
22
|
+
rails_version: ["7.2.2.1", "8.0.2"]
|
23
|
+
blacklight_version: ["8.8.4"]
|
24
24
|
include:
|
25
|
-
- ruby: "3.1"
|
26
|
-
rails_version: "6.1.7.8"
|
27
25
|
- ruby: "3.2"
|
28
|
-
rails_version: "7.
|
26
|
+
rails_version: "7.1.3.4"
|
29
27
|
- ruby: "3.3"
|
30
28
|
rails_version: "7.1.3.4"
|
31
|
-
name: "Blacklight
|
32
|
-
blacklight_version: "
|
29
|
+
name: "Blacklight 7"
|
30
|
+
blacklight_version: "7.38.0"
|
31
|
+
- ruby: "3.4"
|
32
|
+
rails_version: "8.0.2"
|
33
|
+
name: "Blacklight 9 beta"
|
34
|
+
blacklight_version: "9.0.0.beta2"
|
33
35
|
env:
|
34
36
|
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
|
35
37
|
steps:
|
@@ -39,8 +41,6 @@ jobs:
|
|
39
41
|
with:
|
40
42
|
ruby-version: ${{ matrix.ruby }}
|
41
43
|
bundler: latest
|
42
|
-
- name: Change permissions
|
43
|
-
run: "chmod -f -R o-w /opt/hostedtoolcache/Ruby/3.2.5/x64/lib/ruby/gems/3.2.0/gems | :"
|
44
44
|
- name: Install dependencies
|
45
45
|
run: bundle install
|
46
46
|
env:
|
@@ -49,4 +49,4 @@ jobs:
|
|
49
49
|
run: bundle exec rake ci
|
50
50
|
env:
|
51
51
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
52
|
-
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test"
|
52
|
+
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-kamal --skip-solid --skip-coffee --skip-test -a propshaft --css=bootstrap"
|
data/README.md
CHANGED
@@ -124,10 +124,6 @@ en:
|
|
124
124
|
toggle_aria_label: Toggle call number section
|
125
125
|
```
|
126
126
|
|
127
|
-
### Javascript
|
128
|
-
|
129
|
-
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.
|
130
|
-
|
131
127
|
## Caveats
|
132
128
|
|
133
129
|
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.
|
@@ -146,3 +142,10 @@ $ npm publish
|
|
146
142
|
- WRITE TESTS
|
147
143
|
- Switch internal facet management from hack-y Hash to `Blacklight::Hierarchy::FacetGroup` class (already implemented, but not plumbed up)
|
148
144
|
- Clarify when suffix is applied/required/etc.
|
145
|
+
|
146
|
+
## Developing gem
|
147
|
+
- Clone locally `git@github.com:sul-dlss/blacklight-hierarchy.git`
|
148
|
+
- go into project directory `cd blacklight-hierarchy`
|
149
|
+
- install dependencies `bundle install`
|
150
|
+
- Create a test app to develop and test against `bundle exec rake engine_cart:generate
|
151
|
+
- Run tests `bundle exec rspec`
|
@@ -1,31 +1,31 @@
|
|
1
|
-
Blacklight.onLoad(
|
2
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior();
|
3
|
-
});
|
1
|
+
Blacklight.onLoad(() => Blacklight.do_hierarchical_facet_expand_contract_behavior())
|
4
2
|
|
5
|
-
(
|
6
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior =
|
7
|
-
|
8
|
-
|
9
|
-
);
|
3
|
+
(() => {
|
4
|
+
Blacklight.do_hierarchical_facet_expand_contract_behavior = () => {
|
5
|
+
const elements = document.querySelectorAll(Blacklight.do_hierarchical_facet_expand_contract_behavior.selector)
|
6
|
+
elements.forEach(elem => Blacklight.hierarchical_facet_expand_contract(elem))
|
10
7
|
}
|
11
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior.selector = '[data-controller="b-h-collapsible"]'
|
12
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior.handle = '[data-action="click->b-h-collapsible#toggle"]'
|
13
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior.list = '[data-b-h-collapsible-target="list"]'
|
8
|
+
Blacklight.do_hierarchical_facet_expand_contract_behavior.selector = '[data-controller="b-h-collapsible"]'
|
9
|
+
Blacklight.do_hierarchical_facet_expand_contract_behavior.handle = '[data-action="click->b-h-collapsible#toggle"]'
|
10
|
+
Blacklight.do_hierarchical_facet_expand_contract_behavior.list = '[data-b-h-collapsible-target="list"]'
|
14
11
|
|
15
|
-
Blacklight.hierarchical_facet_expand_contract =
|
16
|
-
|
17
|
-
li.addClass('twiddle');
|
12
|
+
Blacklight.hierarchical_facet_expand_contract = (element) => {
|
13
|
+
element.classList.add('twiddle')
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
const lists = element.querySelectorAll(Blacklight.do_hierarchical_facet_expand_contract_behavior.list)
|
16
|
+
|
17
|
+
lists.forEach((list) => {
|
18
|
+
if (list.querySelector('span.selected')) {
|
19
|
+
element.classList.add('twiddle-open')
|
20
|
+
const collapseElement = element.querySelector('.collapse')
|
21
|
+
if (collapseElement) {
|
22
|
+
collapseElement.classList.add('show')
|
23
|
+
}
|
23
24
|
}
|
24
|
-
})
|
25
|
+
})
|
25
26
|
|
26
27
|
// attach the toggle behavior to the li tag
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
})(jQuery);
|
28
|
+
const handle = element.querySelector(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle)
|
29
|
+
handle?.addEventListener('click', () => element.classList.toggle('twiddle-open'))
|
30
|
+
}
|
31
|
+
})()
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
module Hierarchy
|
5
|
-
|
5
|
+
superklass = defined?(Blacklight::Facets::ListComponent) ? Blacklight::Facets::ListComponent : Blacklight::FacetFieldListComponent
|
6
|
+
class FacetFieldListComponent < superklass
|
6
7
|
DELIMITER = '_'
|
7
8
|
|
8
9
|
# @param [Blacklight::Configuration::FacetField] as defined in controller with config.add_facet_field (and with :partial => 'blacklight/hierarchy/facet_hierarchy')
|
@@ -28,6 +28,8 @@ module Blacklight
|
|
28
28
|
path = facet_item.value.split(split_regex)
|
29
29
|
loc = tree[facet_field]
|
30
30
|
loc = loc[path.shift] ||= {} while path.length > 0
|
31
|
+
raise(StandardError, "Expected non-empty array after splitting facet value. Original facet value: '#{facet_item.value}'") unless facet_item.value.split(split_regex).present?
|
32
|
+
|
31
33
|
loc[:_] = HierarchicalFacetItem.new(facet_item.value, facet_item.value.split(split_regex).last, facet_item.hits)
|
32
34
|
end
|
33
35
|
end
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
21
|
s.add_dependency 'blacklight', '>= 7.18', '< 9'
|
22
|
-
s.add_dependency 'rails', '>=
|
22
|
+
s.add_dependency 'rails', '>= 7.1', '< 9'
|
23
23
|
s.add_dependency 'deprecation'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rsolr'
|
data/package.json
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Blacklight::Hierarchy::FacetTree do
|
4
|
+
let(:prefix) { 'lc' }
|
5
|
+
let(:facet_display) { { hierarchy: { 'lc' => [['facet'], ':'] } } }
|
6
|
+
let(:display_facet) do
|
7
|
+
instance_double(Blacklight::Solr::Response::Facets::FacetField, name: 'lc_facet', items:, limit: 1001, sort: :index, offset: 0, prefix: nil)
|
8
|
+
end
|
9
|
+
let(:items) do
|
10
|
+
[
|
11
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: ':', value: ':', hits: 100),
|
12
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
13
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:facet_field) do
|
17
|
+
instance_double(
|
18
|
+
Blacklight::FacetFieldPresenter,
|
19
|
+
display_facet:,
|
20
|
+
key: 'lc_facet',
|
21
|
+
label: 'Classification'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
context 'with only valid items' do
|
25
|
+
let(:items) do
|
26
|
+
[
|
27
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
28
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
29
|
+
]
|
30
|
+
end
|
31
|
+
it 'creates HierarchicalFacetItems' do
|
32
|
+
facet_tree = described_class.build(prefix:, facet_display:, facet_field:)
|
33
|
+
expect(facet_tree['lc_facet'].size).to eq(1)
|
34
|
+
expect(facet_tree['lc_facet'].keys.first).to eq('A - General Works')
|
35
|
+
expect(facet_tree['lc_facet']['A - General Works'].keys).to match_array([:_, 'AC - Collections Works'])
|
36
|
+
expect(facet_tree['lc_facet']['A - General Works'][:_]).to be_an_instance_of(HierarchicalFacetItem)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context 'with an invalid item' do
|
42
|
+
let(:items) do
|
43
|
+
[
|
44
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: ':', value: ':', hits: 100),
|
45
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
46
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'raises an error' do
|
51
|
+
expect do
|
52
|
+
described_class.build(prefix:, facet_display:, facet_field:)
|
53
|
+
end.to raise_error(StandardError, "Expected non-empty array after splitting facet value. Original facet value: ':'")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-hierarchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael B. Klein
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-18 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: blacklight
|
@@ -36,20 +35,20 @@ dependencies:
|
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
38
|
+
version: '7.1'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '9'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
46
45
|
requirements:
|
47
46
|
- - ">="
|
48
47
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
48
|
+
version: '7.1'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '9'
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
name: deprecation
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,13 +179,13 @@ files:
|
|
180
179
|
- package.json
|
181
180
|
- spec/features/basic_spec.rb
|
182
181
|
- spec/helpers/hierarchy_helper_spec.rb
|
182
|
+
- spec/models/blacklight/hierarchy/facet_tree_spec.rb
|
183
183
|
- spec/spec_helper.rb
|
184
184
|
- spec/test_app_templates/Gemfile.extra
|
185
185
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
186
186
|
homepage: https://github.com/sul-dlss/blacklight-hierarchy
|
187
187
|
licenses: []
|
188
188
|
metadata: {}
|
189
|
-
post_install_message:
|
190
189
|
rdoc_options: []
|
191
190
|
require_paths:
|
192
191
|
- lib
|
@@ -201,13 +200,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
200
|
- !ruby/object:Gem::Version
|
202
201
|
version: '0'
|
203
202
|
requirements: []
|
204
|
-
rubygems_version: 3.
|
205
|
-
signing_key:
|
203
|
+
rubygems_version: 3.6.3
|
206
204
|
specification_version: 4
|
207
205
|
summary: Hierarchical Facets for Blacklight
|
208
206
|
test_files:
|
209
207
|
- spec/features/basic_spec.rb
|
210
208
|
- spec/helpers/hierarchy_helper_spec.rb
|
209
|
+
- spec/models/blacklight/hierarchy/facet_tree_spec.rb
|
211
210
|
- spec/spec_helper.rb
|
212
211
|
- spec/test_app_templates/Gemfile.extra
|
213
212
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|