blacklight-hierarchy 5.0.0 → 5.1.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 +8 -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/selected_qfacet_value_component.html.erb +3 -2
- data/app/helpers/blacklight/hierarchy_helper.rb +13 -5
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05896464df5a8c0e3b6d878771afb366c74eb679a9acbb3cc91b48fc1ec21a67'
|
4
|
+
data.tar.gz: f6544b27132185268d971b49e634b6f83a4ad8986e78014f65cc121d233a7fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e239a2df4fac7caf7a0cce0917fd361c04c1a29ba904246275a592769ede706425cf8a4573c2734829f402f43555c76d3b8b393b6a645350644e4aabe60d5659
|
7
|
+
data.tar.gz: c727ad909a5820f59e4484ef3cf517ade8e48ec61646b943d79f1a52991e2eff290a73bc2033f00bfe62d418ddedc1ebb138fa9f246fc8713857cca1aff34028
|
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,23 @@ 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('.toggle-handle').attr('aria-expanded', 'true');
|
23
22
|
}
|
24
23
|
});
|
25
24
|
|
26
25
|
// 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();
|
26
|
+
li.children(Blacklight.do_hierarchical_facet_expand_contract_behavior.handle).click(function(e){
|
27
|
+
li.toggleClass('twiddle-open');
|
32
28
|
});
|
33
29
|
};
|
34
30
|
})(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=\"group\">
|
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,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,25 @@
|
|
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
|
+
target: "##{controls}"
|
21
|
+
},
|
22
|
+
class: 'toggle-handle') do
|
15
23
|
tag.span(Blacklight::Hierarchy::Engine.config.closed_icon, :'aria-hidden' => 'true', class: 'closed') +
|
16
24
|
tag.span(Blacklight::Hierarchy::Engine.config.opened_icon, :'aria-hidden' => 'true', class: 'opened')
|
17
25
|
end
|
@@ -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": "
|
3
|
+
"version": "5.1.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.1.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-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -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
|