blacklight_range_limit 8.2.2 → 8.3.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 +7 -7
- data/Gemfile +11 -6
- data/README.md +5 -14
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +5 -2
- data/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +58 -73
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +6 -3
- data/app/components/blacklight_range_limit/range_facet_component.rb +1 -1
- data/app/components/blacklight_range_limit/range_form_component.html.erb +3 -3
- data/app/components/blacklight_range_limit/range_form_component.rb +12 -1
- data/app/components/blacklight_range_limit/range_segments_component.rb +1 -1
- data/app/presenters/blacklight_range_limit/filter_field.rb +6 -7
- data/blacklight_range_limit.gemspec +3 -3
- data/lib/blacklight_range_limit/engine.rb +0 -8
- data/package.json +29 -0
- data/spec/components/range_form_component_spec.rb +83 -0
- data/spec/features/blacklight_range_limit_spec.rb +1 -0
- data/spec/presenters/filter_field_spec.rb +9 -11
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -7
- metadata +25 -22
- /data/app/assets/stylesheets/{blacklight_range_limit.css.scss → blacklight_range_limit.css} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f27dcb701e35e32cec10ac4e6c203264c1fc5681cc7d754af1085eb8c5cf8e82
|
4
|
+
data.tar.gz: 3189accdc1592a669f87e65729d1fc174794db399b847a43d8b354a2597137d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec927ebe8aff759c1cd16911203cb65f2687c7df61914ee9a01f51d4469eff66f5b41a51c0a17fbaf6bb838f8b8ca5757f6f4df1f70fd66b662b8d55368e67a2
|
7
|
+
data.tar.gz: 772c9541b39355fd40e9c6c822563864bc02ad944a9fec4a2eaa29bb2ebfec7964c826e1e8462f38c38119aee235179dd969a623764c44800a9c3ca95776e812
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,9 +9,9 @@ name: CI
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: [ main ]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
14
|
+
branches: [ main ]
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
test:
|
@@ -20,15 +20,15 @@ jobs:
|
|
20
20
|
strategy:
|
21
21
|
matrix:
|
22
22
|
ruby: [2.7, '3.0']
|
23
|
-
rails_version: ['6.1.
|
23
|
+
rails_version: ['6.1.7.1', '7.0.4.1']
|
24
24
|
additional_engine_cart_rails_options: ['']
|
25
25
|
include:
|
26
|
-
- ruby: '2
|
27
|
-
rails_version: '
|
26
|
+
- ruby: '3.2'
|
27
|
+
rails_version: '7.0.4.1'
|
28
28
|
- ruby: '3.1'
|
29
|
-
rails_version: '7.0.
|
29
|
+
rails_version: '7.0.4.1'
|
30
30
|
- ruby: '3.0'
|
31
|
-
rails_version: '7.0.
|
31
|
+
rails_version: '7.0.4.1'
|
32
32
|
env:
|
33
33
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
34
34
|
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}"
|
data/Gemfile
CHANGED
@@ -10,8 +10,8 @@ group :test do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# BEGIN ENGINE_CART BLOCK
|
13
|
-
# engine_cart:
|
14
|
-
# engine_cart stanza:
|
13
|
+
# engine_cart: 2.5.0
|
14
|
+
# engine_cart stanza: 2.5.0
|
15
15
|
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
16
16
|
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
17
17
|
if File.exist?(file)
|
@@ -31,11 +31,16 @@ else
|
|
31
31
|
else
|
32
32
|
gem 'rails', ENV['RAILS_VERSION']
|
33
33
|
end
|
34
|
-
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
case ENV['RAILS_VERSION']
|
36
|
+
when /^6.0/
|
37
|
+
gem 'sass-rails', '>= 6'
|
38
|
+
gem 'webpacker', '~> 4.0'
|
39
|
+
when /^5.[12]/
|
40
|
+
gem 'sass-rails', '~> 5.0'
|
41
|
+
gem 'sprockets', '~> 3.7'
|
42
|
+
gem 'thor', '~> 0.20'
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
41
46
|
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -102,7 +102,7 @@ config.add_facet_field 'pub_date', label: 'Publication Year',
|
|
102
102
|
|
103
103
|
## Javascript dependencies
|
104
104
|
|
105
|
-
The selectable histograms/barcharts are done with Javascript, using [Flot](http://code.google.com/p/flot/). Flot requires JQuery, as well as support for the HTML5 canvas element.
|
105
|
+
The selectable histograms/barcharts are done with Javascript, using [Flot](http://code.google.com/p/flot/). Flot requires JQuery, as well as support for the HTML5 canvas element. For the slider, [bootstrap-slider](http://www.eyecon.ro/bootstrap-slider/) is used (bootstrap-slider is actually third party, not officially bootstrap). Flot and bootstrap-slider are both directly included in blacklight_range_limit in vendor, rather than referenced as dependencies.
|
106
106
|
|
107
107
|
The blacklight_range_limit installer will add `require 'blacklight_range_limit'` to your `application.js` sprockets manifest. This will include flot, bootstrap-slider, and the blacklight_range_limit glue JS.
|
108
108
|
|
@@ -110,19 +110,6 @@ Both flot and blacklight_range_limit's own JS depend on JQuery; the host app is
|
|
110
110
|
|
111
111
|
If you don't want any of this gem's JS, you can simply remove the `require 'blacklight_range_limit'` line from your application.js, and hack something else together yourself.
|
112
112
|
|
113
|
-
## IE8, excanvas
|
114
|
-
|
115
|
-
IE8 and below do not support the 'canvas' element, needed for flot to render the chart.
|
116
|
-
Without canvas, view will cleanly degrade to an ordinary textual listing of range segments
|
117
|
-
as facets.
|
118
|
-
|
119
|
-
Or, you can use excanvas.js to add canvas support to IE. `blacklight_range_limit` includes
|
120
|
-
the `excanvas.js` file, but you'll have to manually add a reference to it to your Rails layout
|
121
|
-
template -- if you were previously using the stock Blacklight layout, you'll have to add a
|
122
|
-
local custom layout instead. Then add this to the html `<head>` section:
|
123
|
-
|
124
|
-
<!--[if lte IE 8]><%= javascript_include_tag 'flot/excanvas.min' %><![endif]-->
|
125
|
-
|
126
113
|
## Touch?
|
127
114
|
|
128
115
|
For touch screens, one wants the UI to work well. The slider used is
|
@@ -182,6 +169,10 @@ bundle exec rspec spec/features/blacklight_range_limit_spec.rb
|
|
182
169
|
|
183
170
|
Once you are done iterating on your test you will need to stop the application server with `Ctrl-C`.
|
184
171
|
|
172
|
+
# Publishing Javascript
|
173
|
+
|
174
|
+
run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-range-limit
|
175
|
+
|
185
176
|
# Possible future To Do
|
186
177
|
|
187
178
|
* StatsComponent replacement. We use StatsComponent to get min/max of result set, as well as missing count. StatsComponent is included on every non-drilldown request, so ranges and slider can be displayed. However, StatsComponent really can slow down the solr response with a large result set. So replace StatsComponent with other strategies. No ideal ones, we can use facet.missing to get missing count instead, but RSolr makes it harder than it should be to grab this info. We can use seperate solr queries to get min/max (sort on our field, asc and desc), but this is more complicated, more solr queries, and possibly requires redesign of AJAXy stuff, so even a lone slider can have min/max.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
8.
|
1
|
+
8.3.0
|
@@ -31,8 +31,11 @@ Blacklight.onLoad(function() {
|
|
31
31
|
}
|
32
32
|
});
|
33
33
|
|
34
|
+
// Support for Blacklight 7 and 8:
|
35
|
+
const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector
|
36
|
+
|
34
37
|
// When loaded in a modal
|
35
|
-
$(
|
38
|
+
$(modalSelector).on('shown.bs.modal', function() {
|
36
39
|
$(this).find(".range_limit .profile .distribution.chart_js ul").each(function() {
|
37
40
|
BlacklightRangeLimit.turnIntoPlot($(this).parent());
|
38
41
|
});
|
@@ -51,7 +54,7 @@ Blacklight.onLoad(function() {
|
|
51
54
|
// be triggered. The function will be called after it stops being called for
|
52
55
|
// N milliseconds. If `immediate` is passed, trigger the function on the
|
53
56
|
// leading edge, instead of the trailing.
|
54
|
-
debounce = function(func, wait, immediate) {
|
57
|
+
const debounce = function(func, wait, immediate) {
|
55
58
|
var timeout;
|
56
59
|
return function() {
|
57
60
|
var context = this, args = arguments;
|
@@ -1,88 +1,73 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* BlacklightRangeLimit module setup.
|
3
3
|
*/
|
4
|
-
|
5
|
-
'use strict';
|
4
|
+
'use strict';
|
6
5
|
|
7
|
-
|
6
|
+
const BlacklightRangeLimit = function (options) {
|
7
|
+
this.options = options || {};
|
8
|
+
}
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
/* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot
|
15
|
-
is (re-)drawn on screen possibly with a new size. target of event will be the DOM element
|
16
|
-
containing the plot. Used to resize slider to match. */
|
17
|
-
BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit";
|
18
|
-
|
19
|
-
// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma
|
20
|
-
// use in place of javascript's native parseInt
|
21
|
-
BlacklightRangeLimit.parseNum = function parseNum(str) {
|
22
|
-
str = String(str).replace(/[^0-9-]/g, '');
|
23
|
-
return parseInt(str, 10);
|
24
|
-
};
|
10
|
+
BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not
|
11
|
+
/* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot
|
12
|
+
is (re-)drawn on screen possibly with a new size. target of event will be the DOM element
|
13
|
+
containing the plot. Used to resize slider to match. */
|
14
|
+
BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit";
|
25
15
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if (isNaN(end_val) || end_val > max) {
|
33
|
-
end_val = max;
|
34
|
-
}
|
16
|
+
// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma
|
17
|
+
// use in place of javascript's native parseInt
|
18
|
+
BlacklightRangeLimit.parseNum = function parseNum(str) {
|
19
|
+
str = String(str).replace(/[^0-9-]/g, '');
|
20
|
+
return parseInt(str, 10);
|
21
|
+
};
|
35
22
|
|
36
|
-
|
23
|
+
BlacklightRangeLimit.form_selection = function form_selection(form, min, max) {
|
24
|
+
var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val());
|
25
|
+
if (isNaN(begin_val) || begin_val < min) {
|
26
|
+
begin_val = min;
|
37
27
|
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
$(".range_limit .profile .distribution a.load_distribution").each(function() {
|
42
|
-
var container = $(this).parent('div.distribution');
|
43
|
-
|
44
|
-
$(container).load($(this).attr('href'), function(response, status) {
|
45
|
-
if ($(container).hasClass("chart_js") && status == "success" ) {
|
46
|
-
BlacklightRangeLimit.turnIntoPlot(container);
|
47
|
-
}
|
48
|
-
});
|
49
|
-
});
|
28
|
+
var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val());
|
29
|
+
if (isNaN(end_val) || end_val > max) {
|
30
|
+
end_val = max;
|
50
31
|
}
|
51
32
|
|
52
|
-
BlacklightRangeLimit.
|
53
|
-
|
54
|
-
for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
|
55
|
-
var hash = pointer_lookup_arr[i];
|
56
|
-
if (x_coord >= hash.from)
|
57
|
-
return hash;
|
58
|
-
}
|
59
|
-
return pointer_lookup_arr[0];
|
60
|
-
};
|
61
|
-
}
|
33
|
+
return BlacklightRangeLimit.normalized_selection(begin_val, end_val);
|
34
|
+
}
|
62
35
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {
|
68
|
-
max += 0.99999;
|
36
|
+
// Add AJAX fetched range facets if needed, and add a chart to em
|
37
|
+
BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {
|
38
|
+
$(".range_limit .profile .distribution a.load_distribution").each(function() {
|
39
|
+
var container = $(this).parent('div.distribution');
|
69
40
|
|
70
|
-
|
71
|
-
|
41
|
+
$(container).load($(this).attr('href'), function(response, status) {
|
42
|
+
if ($(container).hasClass("chart_js") && status == "success" ) {
|
43
|
+
BlacklightRangeLimit.turnIntoPlot(container);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
});
|
47
|
+
}
|
72
48
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
49
|
+
BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {
|
50
|
+
return function(x_coord) {
|
51
|
+
for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
|
52
|
+
var hash = pointer_lookup_arr[i];
|
53
|
+
if (x_coord >= hash.from)
|
54
|
+
return hash;
|
55
|
+
}
|
56
|
+
return pointer_lookup_arr[0];
|
57
|
+
};
|
58
|
+
}
|
78
59
|
|
79
|
-
|
80
|
-
|
60
|
+
// Send endpoint to endpoint+0.99999 to have display
|
61
|
+
// more closely approximate limiting behavior esp
|
62
|
+
// at small resolutions. (Since we search on whole numbers,
|
63
|
+
// inclusive, but flot chart is decimal.)
|
64
|
+
BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {
|
65
|
+
max += 0.99999;
|
81
66
|
|
82
|
-
|
83
|
-
|
84
|
-
return BlacklightRangeLimit;
|
85
|
-
};
|
67
|
+
return {xaxis: { 'from':min, 'to':max}}
|
68
|
+
}
|
86
69
|
|
87
|
-
|
88
|
-
|
70
|
+
// Check if Flot is loaded
|
71
|
+
BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {
|
72
|
+
return typeof $.plot != "undefined"
|
73
|
+
}
|
@@ -6,7 +6,10 @@ Blacklight.onLoad(function() {
|
|
6
6
|
BlacklightRangeLimit.buildSlider(this);
|
7
7
|
});
|
8
8
|
|
9
|
-
|
9
|
+
// Support for Blacklight 7 and 8:
|
10
|
+
const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector
|
11
|
+
|
12
|
+
$(modalSelector).on('shown.bs.modal', function() {
|
10
13
|
$(this).find(".range_limit .profile .range.slider_js").each(function() {
|
11
14
|
BlacklightRangeLimit.buildSlider(this);
|
12
15
|
});
|
@@ -31,8 +34,8 @@ Blacklight.onLoad(function() {
|
|
31
34
|
// Will return NaN as min or max in case of error or other weirdness.
|
32
35
|
BlacklightRangeLimit.min_max = function min_max(range_element) {
|
33
36
|
var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current")
|
34
|
-
|
35
|
-
|
37
|
+
let min, max
|
38
|
+
min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'))
|
36
39
|
if ( isNaN(min)) {
|
37
40
|
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
|
38
41
|
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BlacklightRangeLimit
|
4
|
-
class RangeFacetComponent < ::
|
4
|
+
class RangeFacetComponent < Blacklight::Component
|
5
5
|
renders_one :more_link, ->(key:, label:) do
|
6
6
|
tag.div class: 'more_facets' do
|
7
7
|
link_to t('blacklight.range_limit.view_larger', field_name: label),
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%= form_tag search_action_path, method: :get, class: [@classes[:form], "range_#{@facet_field.key} d-flex justify-content-center"].join(' ') do %>
|
2
|
-
<%= render
|
2
|
+
<%= render hidden_search_state %>
|
3
3
|
|
4
4
|
<div class="input-group input-group-sm mb-3 flex-nowrap range-limit-input-group">
|
5
5
|
<%= render_range_input(:begin, begin_label) %>
|
6
6
|
<%= render_range_input(:end, end_label) %>
|
7
7
|
<div class="input-group-append visually-hidden">
|
8
|
-
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: @classes[:submit] %>
|
8
|
+
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: @classes[:submit], name: nil %>
|
9
9
|
</div>
|
10
|
-
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: @classes[:submit] + " sr-only", "aria-hidden": "true" %>
|
10
|
+
<%= submit_tag t('blacklight.range_limit.submit_limit'), class: @classes[:submit] + " sr-only", "aria-hidden": "true", name: nil %>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BlacklightRangeLimit
|
4
|
-
class RangeFormComponent < ::
|
4
|
+
class RangeFormComponent < Blacklight::Component
|
5
5
|
delegate :search_action_path, to: :helpers
|
6
6
|
|
7
7
|
def initialize(facet_field:, classes: BlacklightRangeLimit.classes)
|
@@ -39,6 +39,17 @@ module BlacklightRangeLimit
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
+
##
|
43
|
+
# the form needs to serialize any search parameters, including other potential range filters,
|
44
|
+
# as hidden fields. The parameters for this component's range filter are serialized as number
|
45
|
+
# inputs, and should not be in the hidden params.
|
46
|
+
# @return [Blacklight::HiddenSearchStateComponent]
|
47
|
+
def hidden_search_state
|
48
|
+
hidden_search_params = @facet_field.search_state.params_for_search.except(:utf8, :page)
|
49
|
+
hidden_search_params[:range]&.except!(@facet_field.key)
|
50
|
+
Blacklight::HiddenSearchStateComponent.new(params: hidden_search_params)
|
51
|
+
end
|
52
|
+
|
42
53
|
def range_config
|
43
54
|
@facet_field.range_config
|
44
55
|
end
|
@@ -53,12 +53,12 @@ module BlacklightRangeLimit
|
|
53
53
|
range = if params.dig(param_key, config.key).is_a? Range
|
54
54
|
params.dig(param_key, config.key)
|
55
55
|
elsif params.dig(param_key, config.key).is_a? Hash
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
b_bound = params.dig(param_key, config.key, :begin).presence
|
57
|
+
e_bound = params.dig(param_key, config.key, :end).presence
|
58
|
+
Range.new(b_bound&.to_i, e_bound&.to_i) if b_bound && e_bound
|
59
59
|
end
|
60
60
|
|
61
|
-
f = except.include?(:filters) ? [] :
|
61
|
+
f = except.include?(:filters) ? [] : [range].compact
|
62
62
|
|
63
63
|
f_missing = [] if except.include?(:missing)
|
64
64
|
f_missing ||= [Blacklight::SearchState::FilterField::MISSING] if params.dig(filters_key, "-#{key}")&.any? { |v| v == Blacklight::Engine.config.blacklight.facet_missing_param }
|
@@ -75,9 +75,8 @@ module BlacklightRangeLimit
|
|
75
75
|
# this filter should allow (expect) hashes if the keys include 'begin' or 'end'
|
76
76
|
def permitted_params
|
77
77
|
{
|
78
|
-
|
79
|
-
|
80
|
-
inclusive_filters_key => { config.key => { begin: [], end: [] } }
|
78
|
+
filters_key => { config.key => [:begin, :end], "-#{config.key}" => [] },
|
79
|
+
inclusive_filters_key => { config.key => [:begin, :end] }
|
81
80
|
}
|
82
81
|
end
|
83
82
|
end
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.license = 'Apache 2.0'
|
19
19
|
|
20
|
-
s.add_dependency 'blacklight', '>= 7.
|
20
|
+
s.add_dependency 'blacklight', '>= 7.25.2', '< 9'
|
21
|
+
s.add_dependency 'deprecation'
|
21
22
|
|
22
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
s.add_development_dependency 'rspec-rails'
|
@@ -27,6 +28,5 @@ Gem::Specification.new do |s|
|
|
27
28
|
s.add_development_dependency 'solr_wrapper'
|
28
29
|
s.add_development_dependency 'engine_cart', '~> 2.1'
|
29
30
|
s.add_development_dependency 'selenium-webdriver', '>= 3.13.1'
|
30
|
-
s.add_development_dependency 'webdrivers', '~>
|
31
|
-
s.add_development_dependency 'rexml' # pending https://github.com/SeleniumHQ/selenium/issues/9001
|
31
|
+
s.add_development_dependency 'webdrivers', '~>5.0'
|
32
32
|
end
|
@@ -4,14 +4,6 @@ require 'rails'
|
|
4
4
|
|
5
5
|
module BlacklightRangeLimit
|
6
6
|
class Engine < Rails::Engine
|
7
|
-
# Need to tell asset pipeline to precompile the excanvas
|
8
|
-
# we use for IE.
|
9
|
-
initializer "blacklight_range_limit.assets", :after => "assets" do
|
10
|
-
if defined? Sprockets
|
11
|
-
Rails.application.config.assets.precompile += %w( flot/excanvas.min.js )
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
7
|
config.action_dispatch.rescue_responses.merge!(
|
16
8
|
"BlacklightRangeLimit::InvalidRange" => :not_acceptable
|
17
9
|
)
|
data/package.json
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"name": "blacklight-range-limit",
|
3
|
+
"version": "8.3.0",
|
4
|
+
"description": "A range facet UI component plugin for blacklight",
|
5
|
+
"main": "app/assets/javascripts/blacklight_range_limit",
|
6
|
+
"scripts": {
|
7
|
+
},
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git+https://github.com/projectblacklight/blacklight_range_limit.git"
|
11
|
+
},
|
12
|
+
"files": [
|
13
|
+
"app/assets", "vendor/assets"
|
14
|
+
],
|
15
|
+
"author": "",
|
16
|
+
"license": "Apache-2.0",
|
17
|
+
"bugs": {
|
18
|
+
"url": "https://github.com/projectblacklight/blacklight_range_limit/issues"
|
19
|
+
},
|
20
|
+
"homepage": "https://github.com/projectblacklight/blacklight_range_limit#readme",
|
21
|
+
"devDependencies": {
|
22
|
+
},
|
23
|
+
"browserslist": [
|
24
|
+
"defaults",
|
25
|
+
"not IE 11"
|
26
|
+
],
|
27
|
+
"dependencies": {
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe BlacklightRangeLimit::RangeFormComponent, type: :component do
|
6
|
+
subject(:component) do
|
7
|
+
described_class.new(facet_field: facet_field)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:rendered) do
|
11
|
+
Capybara::Node::Simple.new(render_inline(component))
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:facet_field_params) { {} }
|
15
|
+
let(:selected_range) { nil }
|
16
|
+
let(:search_params) { { another_field: 'another_value' } }
|
17
|
+
|
18
|
+
let(:facet_field) do
|
19
|
+
instance_double(
|
20
|
+
BlacklightRangeLimit::FacetFieldPresenter,
|
21
|
+
key: 'key',
|
22
|
+
html_id: 'id',
|
23
|
+
active?: false,
|
24
|
+
collapsed?: false,
|
25
|
+
in_modal?: false,
|
26
|
+
label: 'My facet field',
|
27
|
+
selected_range: selected_range,
|
28
|
+
selected_range_facet_item: nil,
|
29
|
+
missing_facet_item: nil,
|
30
|
+
missing_selected?: false,
|
31
|
+
min: nil,
|
32
|
+
max: nil,
|
33
|
+
search_state: Blacklight::SearchState.new(search_params, nil),
|
34
|
+
range_config: {},
|
35
|
+
modal_path: nil,
|
36
|
+
facet_field: facet_config,
|
37
|
+
**facet_field_params
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:facet_config) do
|
42
|
+
Blacklight::Configuration::FacetField.new(key: 'key', item_presenter: BlacklightRangeLimit::FacetItemPresenter)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'renders a form with no selected range' do
|
46
|
+
expect(rendered).to have_selector('form[action="http://test.host/catalog"][method="get"]')
|
47
|
+
.and have_field('range[key][begin]', type: 'number')
|
48
|
+
.and have_field('range[key][end]', type: 'number')
|
49
|
+
.and have_field('another_field', type: 'hidden', with: 'another_value', visible: false)
|
50
|
+
expect(rendered.find_field('range[key][begin]', type: 'number').value).to be_blank
|
51
|
+
expect(rendered.find_field('range[key][end]', type: 'number').value).to be_blank
|
52
|
+
expect(rendered).not_to have_field('range[key][begin]', type: 'hidden')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'renders submit controls without a name to suppress from formData' do
|
56
|
+
anon_submit = rendered.find('input', visible: true) { |ele| ele[:type] == 'submit' && !ele[:'aria-hidden'] && !ele[:name] }
|
57
|
+
expect(anon_submit).to be_present
|
58
|
+
expect { rendered.find('input') { |ele| ele[:type] == 'submit' && ele[:name] } }.to raise_error(Capybara::ElementNotFound)
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with range data' do
|
62
|
+
let(:selected_range) { (100..300) }
|
63
|
+
let(:search_params) do
|
64
|
+
{
|
65
|
+
another_field: 'another_value',
|
66
|
+
range: {
|
67
|
+
another_range: { begin: 128, end: 1024 },
|
68
|
+
key: { begin: selected_range.first, end: selected_range.last }
|
69
|
+
}
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'renders a form for the selected range' do
|
74
|
+
expect(rendered).to have_selector('form[action="http://test.host/catalog"][method="get"]')
|
75
|
+
.and have_field('range[key][begin]', type: 'number', with: selected_range.first)
|
76
|
+
.and have_field('range[key][end]', type: 'number', with: selected_range.last)
|
77
|
+
.and have_field('another_field', type: 'hidden', with: 'another_value', visible: false)
|
78
|
+
.and have_field('range[another_range][begin]', type: 'hidden', with: 128, visible: false)
|
79
|
+
.and have_field('range[another_range][end]', type: 'hidden', with: 1024, visible: false)
|
80
|
+
expect(rendered).not_to have_field('range[key][begin]', type: 'hidden')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -42,6 +42,7 @@ describe "Blacklight Range Limit" do
|
|
42
42
|
click_link '2000 to 2008'
|
43
43
|
click_button 'Apply', match: :first
|
44
44
|
expect(page.current_url).not_to include('page')
|
45
|
+
expect(page.current_url).not_to include('commit')
|
45
46
|
end
|
46
47
|
|
47
48
|
context 'when I18n translation is available' do
|
@@ -55,6 +55,15 @@ RSpec.describe BlacklightRangeLimit::FilterField do
|
|
55
55
|
expect(filter.include?(1234..2345)).to eq false
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
describe '#permitted_params' do
|
60
|
+
let(:rails_params) { ActionController::Parameters.new(param_values) }
|
61
|
+
let(:blacklight_params) { Blacklight::Parameters.new(rails_params, search_state) }
|
62
|
+
let(:permitted_params) { blacklight_params.permit_search_params.to_h }
|
63
|
+
it 'sanitizes single begin/end values as scalars' do
|
64
|
+
expect(permitted_params.dig(:range, 'some_field')).to include 'begin' => '2013', 'end' => '2022'
|
65
|
+
end
|
66
|
+
end
|
58
67
|
end
|
59
68
|
|
60
69
|
context 'with empty data' do
|
@@ -76,15 +85,4 @@ RSpec.describe BlacklightRangeLimit::FilterField do
|
|
76
85
|
end
|
77
86
|
end
|
78
87
|
end
|
79
|
-
|
80
|
-
|
81
|
-
context 'with array-mangled data' do
|
82
|
-
let(:param_values) { { range: { some_field: { begin: { '0' => '2013' }, end: { '0' => '2022' } } } } }
|
83
|
-
|
84
|
-
describe '#values' do
|
85
|
-
it 'converts the parameters to a Range' do
|
86
|
-
expect(filter.values).to eq [2013..2022]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
88
|
end
|
@@ -30,11 +30,4 @@ class TestAppGenerator < Rails::Generators::Base
|
|
30
30
|
"\n config.add_facet_field 'pub_date_si', label: 'Publication Date Sort', **default_range_config"
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
def assets
|
35
|
-
return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4'
|
36
|
-
|
37
|
-
append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
|
38
|
-
empty_directory 'app/assets/images'
|
39
|
-
end
|
40
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_range_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blacklight
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 7.
|
20
|
+
version: 7.25.2
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '9'
|
@@ -27,10 +27,24 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 7.
|
30
|
+
version: 7.25.2
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '9'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: deprecation
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
34
48
|
- !ruby/object:Gem::Dependency
|
35
49
|
name: rspec
|
36
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,28 +163,14 @@ dependencies:
|
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
166
|
+
version: '5.0'
|
153
167
|
type: :development
|
154
168
|
prerelease: false
|
155
169
|
version_requirements: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
160
|
-
- !ruby/object:Gem::Dependency
|
161
|
-
name: rexml
|
162
|
-
requirement: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
type: :development
|
168
|
-
prerelease: false
|
169
|
-
version_requirements: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
173
|
+
version: '5.0'
|
174
174
|
description:
|
175
175
|
email:
|
176
176
|
- blacklight-development@googlegroups.com
|
@@ -192,7 +192,7 @@ files:
|
|
192
192
|
- app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js
|
193
193
|
- app/assets/javascripts/blacklight_range_limit/range_limit_shared.js
|
194
194
|
- app/assets/javascripts/blacklight_range_limit/range_limit_slider.js
|
195
|
-
- app/assets/stylesheets/blacklight_range_limit.css
|
195
|
+
- app/assets/stylesheets/blacklight_range_limit.css
|
196
196
|
- app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css
|
197
197
|
- app/components/blacklight_range_limit/range_facet_component.html.erb
|
198
198
|
- app/components/blacklight_range_limit/range_facet_component.rb
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/generators/blacklight_range_limit/assets_generator.rb
|
230
230
|
- lib/generators/blacklight_range_limit/install_generator.rb
|
231
231
|
- lib/tasks/blacklight_range_limit.rake
|
232
|
+
- package.json
|
232
233
|
- solr/conf/_rest_managed.json
|
233
234
|
- solr/conf/admin-extra.html
|
234
235
|
- solr/conf/elevate.xml
|
@@ -247,6 +248,7 @@ files:
|
|
247
248
|
- solr/conf/xslt/luke.xsl
|
248
249
|
- solr/sample_solr_documents.yml
|
249
250
|
- spec/components/range_facet_component_spec.rb
|
251
|
+
- spec/components/range_form_component_spec.rb
|
250
252
|
- spec/features/a_javascript_spec.rb
|
251
253
|
- spec/features/blacklight_range_limit_spec.rb
|
252
254
|
- spec/fixtures/solr_documents/unknown_year.yml
|
@@ -291,12 +293,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
293
|
- !ruby/object:Gem::Version
|
292
294
|
version: '0'
|
293
295
|
requirements: []
|
294
|
-
rubygems_version: 3.
|
296
|
+
rubygems_version: 3.3.26
|
295
297
|
signing_key:
|
296
298
|
specification_version: 4
|
297
299
|
summary: Blacklight Range Limit plugin
|
298
300
|
test_files:
|
299
301
|
- spec/components/range_facet_component_spec.rb
|
302
|
+
- spec/components/range_form_component_spec.rb
|
300
303
|
- spec/features/a_javascript_spec.rb
|
301
304
|
- spec/features/blacklight_range_limit_spec.rb
|
302
305
|
- spec/fixtures/solr_documents/unknown_year.yml
|
File without changes
|