blacklight-hierarchy 5.0.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -2
- data/app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js +12 -0
- data/app/assets/javascripts/blacklight/hierarchy/hierarchy.js +9 -12
- data/app/components/blacklight/hierarchy/facet_field_component.html.erb +4 -3
- data/app/components/blacklight/hierarchy/facet_field_component.rb +5 -0
- data/app/components/blacklight/hierarchy/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/hierarchy/selected_qfacet_value_component.html.erb +3 -2
- data/app/helpers/blacklight/hierarchy_helper.rb +15 -5
- data/blacklight-hierarchy.gemspec +1 -1
- data/lib/blacklight/hierarchy/version.rb +1 -1
- data/lib/generators/blacklight_hierarchy/templates/blacklight_hierarchy.js +9 -1
- data/package.json +1 -1
- data/spec/features/basic_spec.rb +2 -2
- data/spec/helpers/hierarchy_helper_spec.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f94c79bf8bbe805effc4bec475a954cf3dc958eb6e4bed158c72432ff21c63e
|
4
|
+
data.tar.gz: 2f2b214a450f319ba642b309646162833a8205b6081bd03b81e8fb254cf884a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66a38ecc4ffa59c73d6121110cf7fdb9dab24a56d5001e3b3e9a262595d3e5b47c9af52b8b7b1a38006b94d9794c2984e8a2610c698cc3432ddd6189fff0c816
|
7
|
+
data.tar.gz: 4b7274458273f4c9f86f3f93de9af1adbb15d5e03dc7519d12f9700763cd73ca27f7d2e5f17d18836ee537230da27dd9d7e4ac7ec785d048ca54e75a9b68a926
|
data/.github/workflows/ruby.yml
CHANGED
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
runs-on: ubuntu-latest
|
19
19
|
strategy:
|
20
20
|
matrix:
|
21
|
-
ruby: [2.
|
21
|
+
ruby: [2.7, 3.0]
|
22
22
|
steps:
|
23
23
|
- uses: actions/checkout@v2
|
24
24
|
- name: Set up Ruby
|
@@ -35,7 +35,7 @@ jobs:
|
|
35
35
|
runs-on: ubuntu-latest
|
36
36
|
strategy:
|
37
37
|
matrix:
|
38
|
-
ruby: [2.
|
38
|
+
ruby: [2.7, 2.6]
|
39
39
|
steps:
|
40
40
|
- uses: actions/checkout@v2
|
41
41
|
- name: Set up Ruby
|
@@ -8,27 +8,24 @@ Blacklight.onLoad(function(){
|
|
8
8
|
Blacklight.hierarchical_facet_expand_contract
|
9
9
|
);
|
10
10
|
}
|
11
|
-
Blacklight.do_hierarchical_facet_expand_contract_behavior.selector = '
|
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"]';
|
12
14
|
|
13
15
|
Blacklight.hierarchical_facet_expand_contract = function() {
|
14
16
|
var li = $(this);
|
17
|
+
li.addClass('twiddle');
|
15
18
|
|
16
|
-
$(
|
17
|
-
|
18
|
-
if($('span.selected', this).length == 0){
|
19
|
-
$(this).hide();
|
20
|
-
} else {
|
19
|
+
$(Blacklight.do_hierarchical_facet_expand_contract_behavior.list, this).each(function() {
|
20
|
+
if($('span.selected', this).length != 0){
|
21
21
|
li.addClass('twiddle-open');
|
22
|
-
li.children('.
|
22
|
+
li.children('.collapse').addClass('in');
|
23
23
|
}
|
24
24
|
});
|
25
25
|
|
26
26
|
// attach the toggle behavior to the li tag
|
27
|
-
li.children(
|
28
|
-
|
29
|
-
$(this).attr('aria-expanded', $(this).attr('aria-expanded') === 'true' ? 'false' : 'true');
|
30
|
-
$(this).parent('li').toggleClass('twiddle-open');
|
31
|
-
$(this).parent('li').children('ul').slideToggle();
|
27
|
+
li.children(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle).click(function(e){
|
28
|
+
li.toggleClass('twiddle-open');
|
32
29
|
});
|
33
30
|
};
|
34
31
|
})(jQuery);
|
@@ -1,5 +1,6 @@
|
|
1
|
-
<li class="<%= li_class %>" role="treeitem">
|
2
|
-
|
1
|
+
<li class="<%= li_class %>" data-controller="<%= controller_name %>" role="treeitem">
|
2
|
+
<% ul_id = "b-h-#{SecureRandom.alphanumeric(10)}" %>
|
3
|
+
<%= helpers.facet_toggle_button(field_name, id, ul_id) if subset.any? %>
|
3
4
|
<% if item.nil? %>
|
4
5
|
<%= key %>
|
5
6
|
<% elsif qfacet_selected? %>
|
@@ -9,7 +10,7 @@
|
|
9
10
|
<% end %>
|
10
11
|
|
11
12
|
<% unless subset.empty? %>
|
12
|
-
<ul role
|
13
|
+
<ul id="<%= ul_id %>" class="collapse" data-b-h-collapsible-target="list" role="group">
|
13
14
|
<% subset.keys.sort.each do |subkey| %>
|
14
15
|
<%= render self.class.new(field_name: field_name, tree: subset[subkey], key: subkey) %>
|
15
16
|
<% end %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%= render(@layout.new(facet_field: @facet_field)) do |component| %>
|
2
|
-
<% component.
|
2
|
+
<% component.label do %>
|
3
3
|
<%= @facet_field.label %>
|
4
4
|
<% end %>
|
5
|
-
<% component.
|
5
|
+
<% component.body do %>
|
6
6
|
<ul class="facet-hierarchy" role="tree">
|
7
7
|
<% tree.keys.sort.collect do |key| %>
|
8
8
|
<%= render Blacklight::Hierarchy::FacetFieldComponent.new(field_name: @facet_field.facet_field.field, tree: tree[key], key: key) %>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<span class="selected"><%= render Blacklight::Hierarchy::QfacetValueComponent.new(field_name: field_name, item: item, suppress_link: true) %></span>
|
2
|
-
<%= link_to
|
3
|
-
<span class="
|
2
|
+
<%= link_to(remove_href, class: 'remove') do %>
|
3
|
+
<span class="remove-icon" aria-hidden="true">✖</span>
|
4
|
+
<span class="sr-only"><%= t('blacklight.search.facets.selected.remove') %></span>
|
4
5
|
<% end %>
|
@@ -1,17 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Blacklight::HierarchyHelper
|
4
|
-
def facet_toggle_button(field_name, described_by)
|
4
|
+
def facet_toggle_button(field_name, described_by, controls)
|
5
5
|
aria_label = I18n.t(
|
6
6
|
"blacklight.hierarchy.#{field_name}_toggle_aria_label",
|
7
7
|
default: :'blacklight.hierarchy.toggle_aria_label'
|
8
8
|
)
|
9
9
|
|
10
10
|
# For Rails 5.2 support all options must be symbols. See https://github.com/rails/rails/issues/39813
|
11
|
-
tag.button(:
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
tag.button(aria: {
|
12
|
+
expanded: 'false',
|
13
|
+
label: aria_label,
|
14
|
+
describedby: described_by,
|
15
|
+
controls: controls
|
16
|
+
},
|
17
|
+
data: {
|
18
|
+
action: 'click->b-h-collapsible#toggle',
|
19
|
+
toggle: 'collapse',
|
20
|
+
bs_toggle: 'collapse',
|
21
|
+
target: "##{controls}",
|
22
|
+
bs_target: "##{controls}"
|
23
|
+
},
|
24
|
+
class: 'toggle-handle') do
|
15
25
|
tag.span(Blacklight::Hierarchy::Engine.config.closed_icon, :'aria-hidden' => 'true', class: 'closed') +
|
16
26
|
tag.span(Blacklight::Hierarchy::Engine.config.opened_icon, :'aria-hidden' => 'true', class: 'opened')
|
17
27
|
end
|
@@ -18,7 +18,7 @@ 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
|
-
s.add_dependency 'blacklight', '~> 7.
|
21
|
+
s.add_dependency 'blacklight', '~> 7.18'
|
22
22
|
s.add_dependency 'rails', '>= 5.1', '< 7'
|
23
23
|
s.add_dependency 'deprecation'
|
24
24
|
|
@@ -1 +1,9 @@
|
|
1
|
-
//= require blacklight/hierarchy/hierarchy
|
1
|
+
//= require blacklight/hierarchy/hierarchy
|
2
|
+
|
3
|
+
// If you use Stimulus in your application you can remove the line above and require
|
4
|
+
// blacklight_hierarchy_controller instead:
|
5
|
+
//
|
6
|
+
// import BlacklightHierarchyController from 'blacklight-hierarchy/app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller'
|
7
|
+
// import { Application } from 'stimulus'
|
8
|
+
// const application = Application.start()
|
9
|
+
// application.register("b-h-collapsible", BlacklightHierarchyController)
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "blacklight-hierarchy",
|
3
|
-
"version": "4.
|
3
|
+
"version": "5.4.0",
|
4
4
|
"description": "[![Build Status](https://github.com/sul-dlss/blacklight-hierarchy/workflows/CI/badge.svg)](https://github.com/sul-dlss/blacklight-hierarchy/actions?query=branch%3Amain)",
|
5
5
|
"main": "app/assets/javascripts/blacklight/hierarchy/hierarchy.js",
|
6
6
|
"files": [
|
data/spec/features/basic_spec.rb
CHANGED
@@ -31,8 +31,8 @@ shared_examples 'catalog' do
|
|
31
31
|
|
32
32
|
it 'should display the hierarchy' do
|
33
33
|
visit '/'
|
34
|
-
expect(page).to have_selector('li.h-node', text: 'a')
|
35
|
-
expect(page).to have_selector('li.h-node > ul > li.h-node', text: 'b')
|
34
|
+
expect(page).to have_selector('li.h-node[data-controller="b-h-collapsible"]', text: 'a')
|
35
|
+
expect(page).to have_selector('li.h-node > ul > li.h-node[data-controller="b-h-collapsible"]', text: 'b')
|
36
36
|
expect(page).to have_selector('li.h-node li.h-leaf', text: 'c 30')
|
37
37
|
expect(page).to have_selector('li.h-node li.h-leaf', text: 'd 25')
|
38
38
|
expect(page).to have_selector('li.h-node > ul > li.h-node', text: 'c')
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::HierarchyHelper do
|
4
4
|
describe '#facet_toggle_button' do
|
5
|
-
subject { helper.facet_toggle_button(field_name, described_by) }
|
5
|
+
subject { helper.facet_toggle_button(field_name, described_by, 'randomtext123') }
|
6
6
|
let(:field_name) { 'exploded_tag_ssim' }
|
7
7
|
let(:described_by) { 'unique-string' }
|
8
8
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-hierarchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.4.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: 2021-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7.
|
19
|
+
version: '7.18'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '7.
|
26
|
+
version: '7.18'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- LICENSE
|
160
160
|
- README.md
|
161
161
|
- Rakefile
|
162
|
+
- app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js
|
162
163
|
- app/assets/javascripts/blacklight/hierarchy/hierarchy.js
|
163
164
|
- app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss
|
164
165
|
- app/components/blacklight/hierarchy/facet_field_component.html.erb
|