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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26cd69f479cdeed50d1d81525856bb1aaa30f4b308865b4560ec27623d331a6c
4
- data.tar.gz: 1f8fadf9e59ac9dbcf4713bfa86084cb0ef19616bd2c4d1d0c5d400bbc34cdb0
3
+ metadata.gz: 653bcfc6322d881f68b3e497d01f83bae1e50a180734511849d5f3e34abc1cde
4
+ data.tar.gz: eca2782a3f9e8e1573ac4d8ce551bef7c8342e7bc9531d4a75a18da558c180df
5
5
  SHA512:
6
- metadata.gz: 2f7525164912a4e448138ee84f6e911ada7430d140ccce9525ab665bff85fed658e4552cb22d6c4a98c5f8a72aa18bf14e829482c75d1988143911ecc8b954dc
7
- data.tar.gz: 9a799edaa82ababdd09a754d7d737d18005ff24c356a76d5ddbe9e6632935d9e7d8091522d683043f46c960ad18f56ae84ab15968c2e3e2c6e22091e5cf5d805
6
+ metadata.gz: 761b1a427e8ceb7e8839898322469c8d54418308b8d193511570312c7427e6f6e7d15ef4b8afdf78d2bd8b023fc520d4e4204521f7b58988d0a654792d6930c5
7
+ data.tar.gz: a8b501673443997fa510da6a5cc68b3b62832fa514bd39396498df3b203a45fab11c5bccbbf5df7db6c510ddf1eb6a31cc1c49907a8e2219e58b6e79e4e45ab8
@@ -18,18 +18,20 @@ jobs:
18
18
  runs-on: ubuntu-latest
19
19
  strategy:
20
20
  matrix:
21
- ruby: ["3.2", "3.3"]
22
- rails_version: ["7.1.3.4", "7.2.0"]
23
- blacklight_version: ["7.38.0"]
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.0.8.4"
26
+ rails_version: "7.1.3.4"
29
27
  - ruby: "3.3"
30
28
  rails_version: "7.1.3.4"
31
- name: "Blacklight 8.3"
32
- blacklight_version: "8.3.0"
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(function(){
2
- Blacklight.do_hierarchical_facet_expand_contract_behavior();
3
- });
1
+ Blacklight.onLoad(() => Blacklight.do_hierarchical_facet_expand_contract_behavior())
4
2
 
5
- (function($) {
6
- Blacklight.do_hierarchical_facet_expand_contract_behavior = function() {
7
- $( Blacklight.do_hierarchical_facet_expand_contract_behavior.selector ).each (
8
- Blacklight.hierarchical_facet_expand_contract
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 = function() {
16
- var li = $(this);
17
- li.addClass('twiddle');
12
+ Blacklight.hierarchical_facet_expand_contract = (element) => {
13
+ element.classList.add('twiddle')
18
14
 
19
- $(Blacklight.do_hierarchical_facet_expand_contract_behavior.list, this).each(function() {
20
- if($('span.selected', this).length != 0){
21
- li.addClass('twiddle-open');
22
- li.children('.collapse').addClass('show');
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
- li.children(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle).click(function(e){
28
- li.toggleClass('twiddle-open');
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
+ })()
@@ -88,6 +88,7 @@ $text-muted: #777 !default;
88
88
  display: flex;
89
89
  flex-wrap: wrap;
90
90
  padding: 3px 0;
91
+ align-items: center;
91
92
  }
92
93
 
93
94
  .h-leaf {
@@ -2,7 +2,8 @@
2
2
 
3
3
  module Blacklight
4
4
  module Hierarchy
5
- class FacetFieldListComponent < Blacklight::FacetFieldListComponent
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', '>= 6.1', '< 7.3'
22
+ s.add_dependency 'rails', '>= 7.1', '< 9'
23
23
  s.add_dependency 'deprecation'
24
24
 
25
25
  s.add_development_dependency 'rsolr'
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Hierarchy
3
- VERSION = '6.4.0'.freeze
3
+ VERSION = '6.6.0'.freeze
4
4
  end
5
5
  end
data/package.json CHANGED
@@ -19,7 +19,6 @@
19
19
  "homepage": "https://github.com/sul-dlss/blacklight-hierarchy#readme",
20
20
  "devDependencies": {},
21
21
  "dependencies": {
22
- "blacklight-frontend": ">=7.1 || 8.0",
23
- "jquery": ">=3.0"
22
+ "blacklight-frontend": ">=7.1 <10.0.0"
24
23
  }
25
24
  }
@@ -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.0
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: 2024-08-13 00:00:00.000000000 Z
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: '6.1'
38
+ version: '7.1'
40
39
  - - "<"
41
40
  - !ruby/object:Gem::Version
42
- version: '7.3'
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: '6.1'
48
+ version: '7.1'
50
49
  - - "<"
51
50
  - !ruby/object:Gem::Version
52
- version: '7.3'
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.5.15
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