blacklight_range_limit 8.5.0 → 9.0.0.beta1
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 +117 -26
- data/.gitignore +2 -1
- data/.solr_wrapper.yml +8 -0
- data/Gemfile +7 -1
- data/README.md +77 -86
- data/Rakefile +31 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight-range-limit/index.js +345 -0
- data/app/components/blacklight_range_limit/range_facet_component.html.erb +29 -27
- data/app/components/blacklight_range_limit/range_facet_component.rb +15 -9
- data/app/components/blacklight_range_limit/range_form_component.html.erb +13 -5
- data/app/components/blacklight_range_limit/range_form_component.rb +8 -20
- data/app/presenters/blacklight_range_limit/facet_field_presenter.rb +13 -2
- data/app/presenters/blacklight_range_limit/facet_item_presenter.rb +6 -11
- data/app/presenters/blacklight_range_limit/filter_field.rb +2 -2
- data/blacklight_range_limit.gemspec +1 -1
- data/config/importmap.rb +9 -0
- data/config/locales/blacklight_range_limit.ar.yml +13 -8
- data/config/locales/blacklight_range_limit.de.yml +13 -8
- data/config/locales/blacklight_range_limit.en.yml +5 -1
- data/config/locales/blacklight_range_limit.es.yml +18 -0
- data/config/locales/blacklight_range_limit.it.yml +13 -8
- data/lib/blacklight_range_limit/controller_override.rb +1 -25
- data/lib/blacklight_range_limit/engine.rb +48 -0
- data/lib/blacklight_range_limit/range_limit_builder.rb +40 -3
- data/lib/blacklight_range_limit.rb +8 -31
- data/lib/generators/blacklight_range_limit/assets_generator.rb +82 -18
- data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
- data/lib/generators/blacklight_range_limit/jsbundling_bl7_fixup_generator.rb +98 -0
- data/package-lock.json +8 -7
- data/package.json +10 -14
- data/spec/components/range_facet_component_spec.rb +41 -32
- data/spec/components/range_form_component_spec.rb +2 -2
- data/spec/components/range_segments_component_spec.rb +64 -0
- data/spec/features/blacklight_range_limit_spec.rb +21 -13
- data/spec/features/run_through_spec.rb +157 -0
- data/spec/presenters/facet_field_presenter_spec.rb +72 -0
- data/spec/presenters/filter_field_spec.rb +36 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/test_app_templates/Gemfile.extra +11 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -6
- metadata +25 -51
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js +0 -534
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js +0 -542
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit.js +0 -27
- data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +0 -60
- data/app/assets/stylesheets/blacklight_range_limit.css +0 -7
- data/app/helpers/range_limit_helper.rb +0 -130
- data/app/javascript/blacklight_range_limit/index.js +0 -11
- data/app/javascript/blacklight_range_limit/range_limit_distro_facets.js +0 -76
- data/app/javascript/blacklight_range_limit/range_limit_plotting.js +0 -186
- data/app/javascript/blacklight_range_limit/range_limit_shared.js +0 -112
- data/app/javascript/blacklight_range_limit/range_limit_slider.js +0 -163
- data/app/javascripts/blacklight_range_limit/index.js +0 -13
- data/app/views/blacklight_range_limit/_range_segments.html.erb +0 -8
- data/app/views/blacklight_range_limit/range_segments.html.erb +0 -1
- data/app/views/catalog/range_limit_panel.html.erb +0 -1
- data/rollup.config.js +0 -37
- data/spec/features/a_javascript_spec.rb +0 -70
- data/spec/helpers/blacklight_range_limit_helper_spec.rb +0 -37
- data/vendor/assets/javascripts/bootstrap-slider.js +0 -388
- data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +0 -549
- data/vendor/assets/javascripts/flot/jquery.colorhelpers.js +0 -199
- data/vendor/assets/javascripts/flot/jquery.event.drag.js +0 -145
- data/vendor/assets/javascripts/flot/jquery.flot.browser.js +0 -98
- data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +0 -662
- data/vendor/assets/javascripts/flot/jquery.flot.hover.js +0 -359
- data/vendor/assets/javascripts/flot/jquery.flot.js +0 -2818
- data/vendor/assets/javascripts/flot/jquery.flot.saturated.js +0 -43
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +0 -527
- data/vendor/assets/javascripts/flot/jquery.flot.uiConstants.js +0 -10
- data/vendor/assets/stylesheets/slider.css +0 -138
@@ -1,163 +0,0 @@
|
|
1
|
-
// for Blacklight.onLoad:
|
2
|
-
import BlacklightRangeLimit from 'range_limit_shared'
|
3
|
-
|
4
|
-
BlacklightRangeLimit.initializeSlider = function(modalSelector) {
|
5
|
-
|
6
|
-
$(".range_limit .profile .range.slider_js").each(function() {
|
7
|
-
BlacklightRangeLimit.buildSlider(this);
|
8
|
-
});
|
9
|
-
|
10
|
-
// For Blacklight < 8, when loaded in a modal
|
11
|
-
$(modalSelector).on('shown.bs.modal', function() {
|
12
|
-
$(this).find(".range_limit .profile .range.slider_js").each(function() {
|
13
|
-
BlacklightRangeLimit.buildSlider(this);
|
14
|
-
});
|
15
|
-
});
|
16
|
-
|
17
|
-
// For Blacklight 8, use a mutation observer to detect when the HTML dialog is open
|
18
|
-
BlacklightRangeLimit.initSliderModalObserver(modalSelector);
|
19
|
-
|
20
|
-
// catch event for redrawing chart, to redraw slider to match width
|
21
|
-
$("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
|
22
|
-
var area = $(event.target).closest(".limit_content.range_limit");
|
23
|
-
var plot = area.find(".chart_js").data("plot");
|
24
|
-
var slider_el = area.find(".slider");
|
25
|
-
|
26
|
-
if (plot && slider_el) {
|
27
|
-
slider_el.width(plot.width());
|
28
|
-
slider_el.css("display", "block")
|
29
|
-
}
|
30
|
-
});
|
31
|
-
}
|
32
|
-
|
33
|
-
// returns two element array min/max as numbers. If there is a limit applied,
|
34
|
-
// it's boundaries are are limits. Otherwise, min/max in current result
|
35
|
-
// set as sniffed from HTML. Pass in a DOM element for a div.range
|
36
|
-
// Will return NaN as min or max in case of error or other weirdness.
|
37
|
-
BlacklightRangeLimit.min_max = function min_max(range_element) {
|
38
|
-
var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current")
|
39
|
-
let min, max
|
40
|
-
min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'))
|
41
|
-
if ( isNaN(min)) {
|
42
|
-
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
|
43
|
-
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
|
44
|
-
}
|
45
|
-
|
46
|
-
if (isNaN(min) || isNaN(max)) {
|
47
|
-
//no current limit, take from results min max included in spans
|
48
|
-
min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
|
49
|
-
max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
|
50
|
-
}
|
51
|
-
return [min, max]
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
// Check to see if a value is an Integer
|
56
|
-
// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
|
57
|
-
BlacklightRangeLimit.isInt = function isInt(n) {
|
58
|
-
return n % 1 === 0;
|
59
|
-
}
|
60
|
-
|
61
|
-
BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {
|
62
|
-
var range_element = $(thisContext);
|
63
|
-
|
64
|
-
var boundaries = BlacklightRangeLimit.min_max(thisContext);
|
65
|
-
var min = boundaries[0];
|
66
|
-
var max = boundaries[1];
|
67
|
-
|
68
|
-
if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {
|
69
|
-
$(thisContext).contents().wrapAll('<div class="sr-only visually-hidden" />');
|
70
|
-
|
71
|
-
var range_element = $(thisContext);
|
72
|
-
var form = $(range_element).closest(".range_limit").find("form.range_limit");
|
73
|
-
var begin_el = form.find("input.range_begin");
|
74
|
-
var end_el = form.find("input.range_end");
|
75
|
-
|
76
|
-
var placeholder_input = $('<input type="hidden" data-slider-placeholder="true" />').appendTo(range_element);
|
77
|
-
|
78
|
-
// make sure slider is loaded
|
79
|
-
if (placeholder_input.slider !== undefined) {
|
80
|
-
placeholder_input.slider({
|
81
|
-
min: min,
|
82
|
-
max: max,
|
83
|
-
value: [min, max],
|
84
|
-
tooltip: "hide"
|
85
|
-
});
|
86
|
-
|
87
|
-
// try to make slider width/orientation match chart's
|
88
|
-
var container = range_element.closest(".range_limit");
|
89
|
-
var plot_el = container.find(".chart_js");
|
90
|
-
var plot = plot_el.data("plot");
|
91
|
-
var slider_el = container.find(".slider");
|
92
|
-
|
93
|
-
if (plot_el) {
|
94
|
-
plot_el.attr('aria-hidden', 'true');
|
95
|
-
}
|
96
|
-
|
97
|
-
if (slider_el) {
|
98
|
-
slider_el.attr('aria-hidden', 'true');
|
99
|
-
}
|
100
|
-
|
101
|
-
if (plot && slider_el) {
|
102
|
-
slider_el.width(plot.width());
|
103
|
-
slider_el.css("display", "block")
|
104
|
-
} else if (slider_el) {
|
105
|
-
slider_el.css("width", "100%");
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
// Slider change should update text input values.
|
110
|
-
var parent = $(thisContext).parent();
|
111
|
-
var form = $(parent).closest(".limit_content").find("form.range_limit");
|
112
|
-
$(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
|
113
|
-
var values = $(event.target).data("slider").getValue();
|
114
|
-
form.find("input.range_begin").val(values[0]);
|
115
|
-
form.find("input.range_end").val(values[1]);
|
116
|
-
});
|
117
|
-
}
|
118
|
-
|
119
|
-
begin_el.val(min);
|
120
|
-
end_el.val(max);
|
121
|
-
|
122
|
-
begin_el.on('input', function() {
|
123
|
-
var val = BlacklightRangeLimit.parseNum(this.value);
|
124
|
-
if (isNaN(val) || val < min) {
|
125
|
-
//for weird data, set slider at min
|
126
|
-
val = min;
|
127
|
-
}
|
128
|
-
var values = placeholder_input.data("slider").getValue();
|
129
|
-
values[0] = val;
|
130
|
-
placeholder_input.slider("setValue", values);
|
131
|
-
});
|
132
|
-
|
133
|
-
end_el.on('input', function() {
|
134
|
-
var val = BlacklightRangeLimit.parseNum(this.value);
|
135
|
-
if (isNaN(val) || val > max) {
|
136
|
-
//weird entry, set slider to max
|
137
|
-
val = max;
|
138
|
-
}
|
139
|
-
var values = placeholder_input.data("slider").getValue();
|
140
|
-
values[1] = val;
|
141
|
-
placeholder_input.slider("setValue", values);
|
142
|
-
});
|
143
|
-
|
144
|
-
begin_el.change(function() {
|
145
|
-
var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
|
146
|
-
var val2 = BlacklightRangeLimit.parseNum(end_el.val());
|
147
|
-
|
148
|
-
if (val2 < val1) {
|
149
|
-
begin_el.val(val2);
|
150
|
-
end_el.val(val1);
|
151
|
-
}
|
152
|
-
});
|
153
|
-
|
154
|
-
end_el.change(function() {
|
155
|
-
var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
|
156
|
-
var val2 = BlacklightRangeLimit.parseNum(end_el.val());
|
157
|
-
|
158
|
-
if (val2 < val1) {
|
159
|
-
begin_el.val(val2);
|
160
|
-
end_el.val(val1);
|
161
|
-
}
|
162
|
-
});
|
163
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import BlacklightRangeLimit from 'range_limit_shared'
|
2
|
-
import RangeLimitDistroFacet from 'range_limit_distro_facets'
|
3
|
-
import RangeLimitSlider from 'range_limit_slider'
|
4
|
-
|
5
|
-
BlacklightRangeLimit.initialize = function() {
|
6
|
-
// Support for Blacklight 7 and 8:
|
7
|
-
const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector
|
8
|
-
|
9
|
-
RangeLimitDistroFacet.initialize(modalSelector)
|
10
|
-
RangeLimitSlider.initialize(modalSelector)
|
11
|
-
}
|
12
|
-
|
13
|
-
export default BlacklightRangeLimit
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<% Deprecation.warn(BlacklightRangeLimit, 'The blacklight_range_limit/range_segments partial is deprecated. Render the RangeSegmentsComponent directly.') %>
|
2
|
-
|
3
|
-
<%
|
4
|
-
facet = blacklight_config.facet_fields[solr_field]
|
5
|
-
display_facet = @response.aggregations[facet.field] || Blacklight::Solr::Response::Facets::FacetField.new(facet.key, [], response: @response)
|
6
|
-
presenter = (facet.presenter || BlacklightRangeLimit::FacetFieldPresenter).new(facet, display_facet, self)
|
7
|
-
%>
|
8
|
-
<%= render BlacklightRangeLimit::RangeSegmentsComponent.new(facet_field: presenter) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render BlacklightRangeLimit::RangeSegmentsComponent.new(facet_field: facet_field) %>
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render template: 'catalog/facet' %>
|
data/rollup.config.js
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
'use strict'
|
2
|
-
|
3
|
-
import includePaths from 'rollup-plugin-includepaths';
|
4
|
-
|
5
|
-
const path = require('path')
|
6
|
-
|
7
|
-
const BUNDLE = process.env.BUNDLE === 'true'
|
8
|
-
const ESM = process.env.ESM === 'true'
|
9
|
-
|
10
|
-
const fileDest = `blacklight_range_limit${ESM ? '.esm' : '.umd'}`
|
11
|
-
const external = []
|
12
|
-
const globals = {}
|
13
|
-
|
14
|
-
let includePathOptions = {
|
15
|
-
include: {},
|
16
|
-
paths: ['app/javascript'],
|
17
|
-
external: [],
|
18
|
-
extensions: ['.js']
|
19
|
-
};
|
20
|
-
|
21
|
-
const rollupConfig = {
|
22
|
-
input: path.resolve(__dirname, `app/javascript/blacklight_range_limit/index.js`),
|
23
|
-
output: {
|
24
|
-
file: path.resolve(__dirname, `app/assets/javascripts/blacklight_range_limit/${fileDest}.js`),
|
25
|
-
format: ESM ? 'esm' : 'umd',
|
26
|
-
globals,
|
27
|
-
generatedCode: 'es2015'
|
28
|
-
},
|
29
|
-
external,
|
30
|
-
plugins: [includePaths(includePathOptions)]
|
31
|
-
}
|
32
|
-
|
33
|
-
if (!ESM) {
|
34
|
-
rollupConfig.output.name = 'BlacklightRangeLimit'
|
35
|
-
}
|
36
|
-
|
37
|
-
module.exports = rollupConfig
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'JavaScript', js: true do
|
6
|
-
it 'initializes canvas chart' do
|
7
|
-
visit search_catalog_path
|
8
|
-
|
9
|
-
click_button 'Publication Date Sort'
|
10
|
-
expect(page).to have_css '.flot-base'
|
11
|
-
end
|
12
|
-
it 'has a View larger modal' do
|
13
|
-
visit search_catalog_path
|
14
|
-
|
15
|
-
click_button 'Publication Date Sort'
|
16
|
-
sleep(1) # resize is debounced
|
17
|
-
click_link 'View larger »'
|
18
|
-
|
19
|
-
within '.modal-body' do
|
20
|
-
expect(page).to have_css '.flot-base'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when assumed boundaries configured' do
|
25
|
-
before do
|
26
|
-
CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = {
|
27
|
-
assumed_boundaries: 1990...2000
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
after do
|
32
|
-
CatalogController.blacklight_config.facet_fields['pub_date_si'].range_config = {}
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should show the range limit with set boundaries' do
|
36
|
-
visit '/catalog'
|
37
|
-
click_button 'Publication Date Sort'
|
38
|
-
expect(page).to have_field :range_pub_date_si_begin, with: '1990'
|
39
|
-
expect(page).to have_field :range_pub_date_si_end, with: '2000'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '"Unknown" link' do
|
44
|
-
context 'when in the facet (e.g. non-xhr)' do
|
45
|
-
it 'is displayed' do
|
46
|
-
visit search_catalog_path
|
47
|
-
|
48
|
-
click_button 'Publication Date Sort'
|
49
|
-
|
50
|
-
within 'ul.subsection.missing' do
|
51
|
-
expect(page).to have_link '[Missing]'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when in the modal (e.g. via xhr)' do
|
57
|
-
it 'is not displayed' do
|
58
|
-
visit search_catalog_path
|
59
|
-
|
60
|
-
click_button 'Publication Date Sort'
|
61
|
-
sleep(1) # resize is debounced
|
62
|
-
click_link 'View larger »'
|
63
|
-
|
64
|
-
within '.modal-body' do
|
65
|
-
expect(page).not_to have_css 'ul.subsection.missing'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Blacklight Range Limit Helper" do
|
4
|
-
let(:config) { Blacklight::Configuration.new }
|
5
|
-
before do
|
6
|
-
allow(helper).to receive(:blacklight_config).and_return(config)
|
7
|
-
allow(helper).to receive(:search_state).and_return(Blacklight::SearchState.new({}, config))
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should render range text fields with/without labels" do
|
11
|
-
begin_html = Capybara.string(helper.render_range_input('pub_date', 'begin'))
|
12
|
-
begin_from_pub_html = Capybara.string(helper.render_range_input('pub_date', 'begin', 'from pub date'))
|
13
|
-
expect(begin_html).to have_css 'input.form-control.range_begin#range_pub_date_begin'
|
14
|
-
expect(begin_from_pub_html).to have_css 'label.sr-only[for="range_pub_date_begin"]'
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should render range text fields with specified maxlength, defaulting to 4 if not specified" do
|
18
|
-
html_maxlength_default = Capybara.string(helper.render_range_input('pub_date', 'begin'))
|
19
|
-
html_maxlength_6 = Capybara.string(helper.render_range_input('pub_date', 'begin', nil, 6))
|
20
|
-
expect(html_maxlength_default).to have_css 'input.form-control.range_begin#range_pub_date_begin[maxlength="4"]'
|
21
|
-
expect(html_maxlength_6).to have_css 'input.form-control.range_begin#range_pub_date_begin[maxlength="6"]'
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when building requests" do
|
25
|
-
it "should exclude page when adding a range" do
|
26
|
-
params = { q: '', page: '2' }
|
27
|
-
updated_params = helper.add_range('test', '1900', '1995', params)
|
28
|
-
expect(updated_params.to_h).not_to include(:page)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should exclude page when adding a missing range" do
|
32
|
-
params = { q: '', page: '2' }
|
33
|
-
updated_params = helper.add_range_missing('test', params)
|
34
|
-
expect(updated_params.to_h).not_to include(:page)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|