blacklight_range_limit 8.4.0 → 9.0.0.beta1
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 +4 -4
- data/.github/workflows/ruby.yml +117 -23
- data/.gitignore +2 -0
- 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 +51 -0
- data/package.json +10 -11
- 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 +26 -44
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +0 -77
- data/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js +0 -185
- data/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +0 -73
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +0 -161
- data/app/assets/javascripts/blacklight_range_limit.js +0 -25
- 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/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/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,161 +0,0 @@
|
|
1
|
-
// for Blacklight.onLoad:
|
2
|
-
|
3
|
-
Blacklight.onLoad(function() {
|
4
|
-
|
5
|
-
$(".range_limit .profile .range.slider_js").each(function() {
|
6
|
-
BlacklightRangeLimit.buildSlider(this);
|
7
|
-
});
|
8
|
-
|
9
|
-
// Support for Blacklight 7 and 8:
|
10
|
-
const modalSelector = Blacklight.modal?.modalSelector || Blacklight.Modal.modalSelector
|
11
|
-
|
12
|
-
$(modalSelector).on('shown.bs.modal', function() {
|
13
|
-
$(this).find(".range_limit .profile .range.slider_js").each(function() {
|
14
|
-
BlacklightRangeLimit.buildSlider(this);
|
15
|
-
});
|
16
|
-
});
|
17
|
-
|
18
|
-
// catch event for redrawing chart, to redraw slider to match width
|
19
|
-
$("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
|
20
|
-
var area = $(event.target).closest(".limit_content.range_limit");
|
21
|
-
var plot = area.find(".chart_js").data("plot");
|
22
|
-
var slider_el = area.find(".slider");
|
23
|
-
|
24
|
-
if (plot && slider_el) {
|
25
|
-
slider_el.width(plot.width());
|
26
|
-
slider_el.css("display", "block")
|
27
|
-
}
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
// returns two element array min/max as numbers. If there is a limit applied,
|
32
|
-
// it's boundaries are are limits. Otherwise, min/max in current result
|
33
|
-
// set as sniffed from HTML. Pass in a DOM element for a div.range
|
34
|
-
// Will return NaN as min or max in case of error or other weirdness.
|
35
|
-
BlacklightRangeLimit.min_max = function min_max(range_element) {
|
36
|
-
var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current")
|
37
|
-
let min, max
|
38
|
-
min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'))
|
39
|
-
if ( isNaN(min)) {
|
40
|
-
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
|
41
|
-
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
|
42
|
-
}
|
43
|
-
|
44
|
-
if (isNaN(min) || isNaN(max)) {
|
45
|
-
//no current limit, take from results min max included in spans
|
46
|
-
min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
|
47
|
-
max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
|
48
|
-
}
|
49
|
-
return [min, max]
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
// Check to see if a value is an Integer
|
54
|
-
// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
|
55
|
-
BlacklightRangeLimit.isInt = function isInt(n) {
|
56
|
-
return n % 1 === 0;
|
57
|
-
}
|
58
|
-
|
59
|
-
BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {
|
60
|
-
var range_element = $(thisContext);
|
61
|
-
|
62
|
-
var boundaries = BlacklightRangeLimit.min_max(thisContext);
|
63
|
-
var min = boundaries[0];
|
64
|
-
var max = boundaries[1];
|
65
|
-
|
66
|
-
if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {
|
67
|
-
$(thisContext).contents().wrapAll('<div class="sr-only visually-hidden" />');
|
68
|
-
|
69
|
-
var range_element = $(thisContext);
|
70
|
-
var form = $(range_element).closest(".range_limit").find("form.range_limit");
|
71
|
-
var begin_el = form.find("input.range_begin");
|
72
|
-
var end_el = form.find("input.range_end");
|
73
|
-
|
74
|
-
var placeholder_input = $('<input type="hidden" data-slider-placeholder="true" />').appendTo(range_element);
|
75
|
-
|
76
|
-
// make sure slider is loaded
|
77
|
-
if (placeholder_input.slider !== undefined) {
|
78
|
-
placeholder_input.slider({
|
79
|
-
min: min,
|
80
|
-
max: max,
|
81
|
-
value: [min, max],
|
82
|
-
tooltip: "hide"
|
83
|
-
});
|
84
|
-
|
85
|
-
// try to make slider width/orientation match chart's
|
86
|
-
var container = range_element.closest(".range_limit");
|
87
|
-
var plot_el = container.find(".chart_js");
|
88
|
-
var plot = plot_el.data("plot");
|
89
|
-
var slider_el = container.find(".slider");
|
90
|
-
|
91
|
-
if (plot_el) {
|
92
|
-
plot_el.attr('aria-hidden', 'true');
|
93
|
-
}
|
94
|
-
|
95
|
-
if (slider_el) {
|
96
|
-
slider_el.attr('aria-hidden', 'true');
|
97
|
-
}
|
98
|
-
|
99
|
-
if (plot && slider_el) {
|
100
|
-
slider_el.width(plot.width());
|
101
|
-
slider_el.css("display", "block")
|
102
|
-
} else if (slider_el) {
|
103
|
-
slider_el.css("width", "100%");
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
// Slider change should update text input values.
|
108
|
-
var parent = $(thisContext).parent();
|
109
|
-
var form = $(parent).closest(".limit_content").find("form.range_limit");
|
110
|
-
$(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
|
111
|
-
var values = $(event.target).data("slider").getValue();
|
112
|
-
form.find("input.range_begin").val(values[0]);
|
113
|
-
form.find("input.range_end").val(values[1]);
|
114
|
-
});
|
115
|
-
}
|
116
|
-
|
117
|
-
begin_el.val(min);
|
118
|
-
end_el.val(max);
|
119
|
-
|
120
|
-
begin_el.on('input', function() {
|
121
|
-
var val = BlacklightRangeLimit.parseNum(this.value);
|
122
|
-
if (isNaN(val) || val < min) {
|
123
|
-
//for weird data, set slider at min
|
124
|
-
val = min;
|
125
|
-
}
|
126
|
-
var values = placeholder_input.data("slider").getValue();
|
127
|
-
values[0] = val;
|
128
|
-
placeholder_input.slider("setValue", values);
|
129
|
-
});
|
130
|
-
|
131
|
-
end_el.on('input', function() {
|
132
|
-
var val = BlacklightRangeLimit.parseNum(this.value);
|
133
|
-
if (isNaN(val) || val > max) {
|
134
|
-
//weird entry, set slider to max
|
135
|
-
val = max;
|
136
|
-
}
|
137
|
-
var values = placeholder_input.data("slider").getValue();
|
138
|
-
values[1] = val;
|
139
|
-
placeholder_input.slider("setValue", values);
|
140
|
-
});
|
141
|
-
|
142
|
-
begin_el.change(function() {
|
143
|
-
var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
|
144
|
-
var val2 = BlacklightRangeLimit.parseNum(end_el.val());
|
145
|
-
|
146
|
-
if (val2 < val1) {
|
147
|
-
begin_el.val(val2);
|
148
|
-
end_el.val(val1);
|
149
|
-
}
|
150
|
-
});
|
151
|
-
|
152
|
-
end_el.change(function() {
|
153
|
-
var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
|
154
|
-
var val2 = BlacklightRangeLimit.parseNum(end_el.val());
|
155
|
-
|
156
|
-
if (val2 < val1) {
|
157
|
-
begin_el.val(val2);
|
158
|
-
end_el.val(val1);
|
159
|
-
}
|
160
|
-
});
|
161
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// Master manifest file for engine, so local app can require
|
2
|
-
// this one file, but get all our files -- and local app
|
3
|
-
// require does not need to change if we change file list.
|
4
|
-
//
|
5
|
-
// Note JQuery is required to be loaded for flot and blacklight_range_limit
|
6
|
-
// JS to work, expect host app to load it.
|
7
|
-
|
8
|
-
|
9
|
-
//= require 'flot/jquery.canvaswrapper.js'
|
10
|
-
//= require 'flot/jquery.colorhelpers.js'
|
11
|
-
//= require 'flot/jquery.flot.js'
|
12
|
-
//= require 'flot/jquery.flot.browser.js'
|
13
|
-
//= require 'flot/jquery.flot.saturated.js'
|
14
|
-
//= require 'flot/jquery.flot.drawSeries.js'
|
15
|
-
//= require 'flot/jquery.event.drag.js'
|
16
|
-
//= require 'flot/jquery.flot.hover.js'
|
17
|
-
//= require 'flot/jquery.flot.uiConstants.js'
|
18
|
-
//= require 'flot/jquery.flot.selection.js'
|
19
|
-
//= require 'bootstrap-slider'
|
20
|
-
|
21
|
-
// Ensure that range_limit_shared is loaded first
|
22
|
-
//= require 'blacklight_range_limit/range_limit_shared'
|
23
|
-
//= require 'blacklight_range_limit/range_limit_plotting'
|
24
|
-
//= require 'blacklight_range_limit/range_limit_slider'
|
25
|
-
//= require 'blacklight_range_limit/range_limit_distro_facets'
|
@@ -1,60 +0,0 @@
|
|
1
|
-
form.range_limit {
|
2
|
-
/* leave room for buttons not to collide on line wrap */
|
3
|
-
line-height: 3;
|
4
|
-
}
|
5
|
-
|
6
|
-
.range_limit .range-limit-input-group {
|
7
|
-
max-width: 350px;
|
8
|
-
width: 100% !important;
|
9
|
-
}
|
10
|
-
|
11
|
-
.range_limit input.range_begin, .range_limit input.range_end {
|
12
|
-
display: inline-block;
|
13
|
-
width: 4.5em;
|
14
|
-
}
|
15
|
-
|
16
|
-
.limit_content .subsection {
|
17
|
-
margin-top: 0.5em;
|
18
|
-
}
|
19
|
-
|
20
|
-
.hover_legend {
|
21
|
-
padding: 0.25em;
|
22
|
-
}
|
23
|
-
|
24
|
-
.slider_js .slider-selection {
|
25
|
-
/* color from flot selection */
|
26
|
-
background: #e8cfac;
|
27
|
-
}
|
28
|
-
|
29
|
-
.slider_js .slider-horizontal {
|
30
|
-
margin-left: 5px;
|
31
|
-
margin-right: 5px;
|
32
|
-
}
|
33
|
-
|
34
|
-
.chart_js .flot-x-axis {
|
35
|
-
font-size: 14px;
|
36
|
-
}
|
37
|
-
|
38
|
-
.modal-body .view_larger {
|
39
|
-
display: none;
|
40
|
-
}
|
41
|
-
|
42
|
-
/* Prevent an unstyled flash of content for values we'll replace with a chart */
|
43
|
-
.js .distribution .facet-values {
|
44
|
-
display: none;
|
45
|
-
}
|
46
|
-
|
47
|
-
.modal-body .range_limit {
|
48
|
-
justify-content: center;
|
49
|
-
}
|
50
|
-
|
51
|
-
.view_larger {
|
52
|
-
display: block;
|
53
|
-
text-align: center;
|
54
|
-
}
|
55
|
-
|
56
|
-
.range_limit .chart_js {
|
57
|
-
min-height: 80px;
|
58
|
-
margin-left: -12px;
|
59
|
-
margin-right: -14px;
|
60
|
-
}
|
@@ -1,130 +0,0 @@
|
|
1
|
-
module RangeLimitHelper
|
2
|
-
extend Deprecation
|
3
|
-
|
4
|
-
def range_limit_url(options = {})
|
5
|
-
main_app.url_for(search_state.to_h.merge(action: 'range_limit').merge(options))
|
6
|
-
end
|
7
|
-
deprecation_deprecate :range_limit_url
|
8
|
-
|
9
|
-
def range_limit_panel_url(options = {})
|
10
|
-
search_facet_path(id: options[:id])
|
11
|
-
end
|
12
|
-
deprecation_deprecate :range_limit_panel_url
|
13
|
-
|
14
|
-
# type is 'begin' or 'end'
|
15
|
-
def render_range_input(solr_field, type, input_label = nil, maxlength=4)
|
16
|
-
range_form_component(solr_field).render_range_input(type, input_label, maxlength)
|
17
|
-
end
|
18
|
-
deprecation_deprecate :render_range_input
|
19
|
-
|
20
|
-
# type is 'min' or 'max'
|
21
|
-
# Returns smallest and largest value in current result set, if available
|
22
|
-
# from stats component response.
|
23
|
-
def range_results_endpoint(solr_field, type)
|
24
|
-
presenter = range_facet_field_presenter(solr_field)
|
25
|
-
|
26
|
-
case type.to_s
|
27
|
-
when 'min'
|
28
|
-
presenter.min
|
29
|
-
when 'max'
|
30
|
-
presenter.max
|
31
|
-
end
|
32
|
-
end
|
33
|
-
deprecation_deprecate :range_results_endpoint
|
34
|
-
|
35
|
-
def range_display(solr_field, my_params = params)
|
36
|
-
facet_config = blacklight_config.facet_fields[solr_field]
|
37
|
-
presenter = range_facet_field_presenter(solr_field)
|
38
|
-
return unless presenter.selected_range
|
39
|
-
|
40
|
-
facet_item = Blacklight::Solr::Response::Facets::FacetItem.new(value: presenter.selected_range, hits: presenter.response.total)
|
41
|
-
|
42
|
-
facet_config.item_presenter.new(facet_item, facet_config, self, solr_field).label
|
43
|
-
end
|
44
|
-
deprecation_deprecate :range_display
|
45
|
-
|
46
|
-
##
|
47
|
-
# A method that is meant to be overridden downstream to format how a range
|
48
|
-
# label might be displayed to a user. By default it just returns the value
|
49
|
-
# as rendered by the presenter
|
50
|
-
def format_range_display_value(value, solr_field)
|
51
|
-
Deprecation.warn(RangeLimitHelper, 'Helper #format_range_display_value is deprecated without replacement')
|
52
|
-
facet_item_presenter(facet_configuration_for_field(solr_field), value, solr_field).label
|
53
|
-
end
|
54
|
-
|
55
|
-
# Show the limit area if:
|
56
|
-
# 1) we have a limit already set
|
57
|
-
# OR
|
58
|
-
# 2) stats show max > min, OR
|
59
|
-
# 3) count > 0 if no stats available.
|
60
|
-
def should_show_limit(solr_field)
|
61
|
-
presenter = range_facet_field_presenter(solr_field)
|
62
|
-
|
63
|
-
presenter.selected_range ||
|
64
|
-
(presenter.max && presenter.min && presenter.max > presenter.min) ||
|
65
|
-
@response.total.positive?
|
66
|
-
end
|
67
|
-
|
68
|
-
def stats_for_field(solr_field)
|
69
|
-
range_facet_field_presenter(solr_field).send(:stats_for_field)
|
70
|
-
end
|
71
|
-
deprecation_deprecate :stats_for_field
|
72
|
-
|
73
|
-
def stats_for_field?(solr_field)
|
74
|
-
stats_for_field(solr_field).present?
|
75
|
-
end
|
76
|
-
deprecation_deprecate :stats_for_field?
|
77
|
-
|
78
|
-
def add_range_missing(solr_field, my_params = params)
|
79
|
-
Blacklight::SearchState.new(my_params.except(:page), blacklight_config).filter(solr_field).add(Blacklight::SearchState::FilterField::MISSING)
|
80
|
-
end
|
81
|
-
deprecation_deprecate :add_range_missing
|
82
|
-
|
83
|
-
def add_range(solr_field, from, to, my_params = params)
|
84
|
-
Blacklight::SearchState.new(my_params.except(:page), blacklight_config).filter(solr_field).add(from..to)
|
85
|
-
end
|
86
|
-
deprecation_deprecate :add_range
|
87
|
-
|
88
|
-
def has_selected_range_limit?(solr_field)
|
89
|
-
range_facet_field_presenter(solr_field).selected_range.present?
|
90
|
-
end
|
91
|
-
deprecation_deprecate :has_selected_range_limit?
|
92
|
-
|
93
|
-
def selected_missing_for_range_limit?(solr_field)
|
94
|
-
search_state.filter(solr_field).values.first == Blacklight::SearchState::FilterField::MISSING
|
95
|
-
end
|
96
|
-
deprecation_deprecate :selected_missing_for_range_limit?
|
97
|
-
|
98
|
-
def remove_range_param(solr_field, my_params = params)
|
99
|
-
Blacklight::SearchState.new(my_params.except(:page), blacklight_config).filter(solr_field).remove(0..0)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Looks in the solr @response for ["facet_counts"]["facet_queries"][solr_field], for elements
|
103
|
-
# expressed as "solr_field:[X to Y]", turns them into
|
104
|
-
# a list of hashes with [:from, :to, :count], sorted by
|
105
|
-
# :from. Assumes integers for sorting purposes.
|
106
|
-
def solr_range_queries_to_a(solr_field)
|
107
|
-
range_facet_field_presenter(solr_field).range_queries.map do |item|
|
108
|
-
{ from: item.value.first, to: item.value.last, count: item.hits }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
deprecation_deprecate :solr_range_queries_to_a
|
112
|
-
|
113
|
-
def range_config(solr_field)
|
114
|
-
BlacklightRangeLimit.range_config(blacklight_config, solr_field)
|
115
|
-
end
|
116
|
-
deprecation_deprecate :range_config
|
117
|
-
|
118
|
-
private
|
119
|
-
|
120
|
-
def range_facet_field_presenter(key)
|
121
|
-
facet_config = blacklight_config.facet_fields[key] || Blacklight::Configuration::FacetField.new(key: key, **BlacklightRangeLimit.default_range_config)
|
122
|
-
facet_field_presenter(facet_config, Blacklight::Solr::Response::Facets::FacetField.new(key, [], response: @response))
|
123
|
-
end
|
124
|
-
|
125
|
-
def range_form_component(key)
|
126
|
-
presenter = range_facet_field_presenter(key)
|
127
|
-
|
128
|
-
BlacklightRangeLimit::RangeFormComponent.new(facet_field: presenter)
|
129
|
-
end
|
130
|
-
end
|
@@ -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' %>
|
@@ -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
|