blacklight_range_limit 2.3.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +2 -2
  2. data/.travis.yml +7 -13
  3. data/Gemfile +8 -34
  4. data/LICENSE +15 -0
  5. data/README.rdoc +25 -7
  6. data/Rakefile +3 -4
  7. data/VERSION +1 -1
  8. data/app/assets/javascripts/blacklight_range_limit.js +5 -2
  9. data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +144 -68
  10. data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +68 -36
  11. data/app/assets/stylesheets/blacklight_range_limit.css.scss +1 -46
  12. data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +12 -2
  13. data/app/helpers/range_limit_helper.rb +7 -1
  14. data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +27 -11
  15. data/app/views/blacklight_range_limit/_range_segments.html.erb +13 -8
  16. data/blacklight_range_limit.gemspec +9 -12
  17. data/config/jetty.yml +7 -2
  18. data/lib/blacklight_range_limit/controller_override.rb +4 -13
  19. data/lib/blacklight_range_limit/route_sets.rb +21 -4
  20. data/lib/blacklight_range_limit/view_helper_override.rb +27 -11
  21. data/lib/generators/blacklight_range_limit/assets_generator.rb +9 -2
  22. data/spec/features/blacklight_range_limit_spec.rb +5 -5
  23. data/spec/spec_helper.rb +7 -1
  24. data/spec/test_app_templates/Gemfile.extra +14 -1
  25. data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -15
  26. data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +0 -6
  27. data/vendor/assets/javascripts/bootstrap-slider.js +388 -0
  28. data/vendor/assets/javascripts/flot/excanvas.min.js +1 -1
  29. data/vendor/assets/javascripts/flot/jquery.flot.js +1328 -790
  30. data/vendor/assets/javascripts/flot/jquery.flot.selection.js +76 -60
  31. data/vendor/assets/stylesheets/slider.css +138 -0
  32. metadata +74 -110
  33. checksums.yaml +0 -7
  34. data/.rspec +0 -1
  35. data/MIT-LICENSE +0 -20
  36. data/solr/sample_solr_documents.yml +0 -641
  37. data/vendor/assets/javascripts/jquery-ui-1.9.2.custom.js +0 -1654
@@ -1,9 +1,8 @@
1
- jQuery(document).ready(function($) {
2
-
3
-
4
-
1
+ // for Blacklight.onLoad:
2
+ //= require blacklight/core
5
3
 
6
-
4
+ Blacklight.onLoad(function() {
5
+
7
6
  $(".range_limit .profile .range.slider_js").each(function() {
8
7
  var range_element = $(this);
9
8
 
@@ -18,42 +17,75 @@ $(".range_limit .profile .range.slider_js").each(function() {
18
17
  var form = $(range_element).closest(".range_limit").find("form.range_limit");
19
18
  var begin_el = form.find("input.range_begin");
20
19
  var end_el = form.find("input.range_end");
20
+
21
+ var placeholder_input = $('<input type="text" data-slider-placeholder="true" style="width:100%;">').appendTo(range_element);
21
22
 
22
- if ($(this).slider) {
23
- $(this).slider({
24
- range: true,
25
- min: min,
26
- max: max+1,
27
- values: [min, max+1],
28
- slide: function(event, ui) {
29
- begin_el.val(ui.values[0]);
30
-
31
- end_el.val(Math.max(ui.values[1]-1, ui.values[0]));
32
- }
33
- });
23
+ // make sure slider is loaded
24
+ if (placeholder_input.slider !== undefined) {
25
+ placeholder_input.slider({
26
+ min: min,
27
+ max: max+1,
28
+ value: [min, max+1],
29
+ tooltip: "hide"
30
+ });
31
+
32
+ // try to make slider width/orientation match chart's
33
+ var container = range_element.closest(".range_limit");
34
+ var plot = container.find(".chart_js").data("plot");
35
+ var slider_el = container.find(".slider");
36
+
37
+ if (plot && slider_el) {
38
+ slider_el.width(plot.width());
39
+ slider_el.css("display", "block")
40
+ slider_el.css('margin-right', 'auto');
41
+ slider_el.css('margin-left', 'auto');
42
+ }
43
+ else if (slider_el) {
44
+ slider_el.css("width", "100%");
45
+ }
34
46
  }
47
+ }
48
+
35
49
 
36
- begin_el.val(min);
37
- end_el.val(max);
50
+ begin_el.val(min);
51
+ end_el.val(max);
38
52
 
39
- begin_el.change( function() {
40
- var val = parseInt($(this).val());
41
- if ( isNaN(val) || val < min) {
42
- //for weird data, set slider at min
43
- val = min;
44
- }
45
- range_element.slider("values", 0, val);
46
- });
53
+ begin_el.change( function() {
54
+ var val = parseInt($(this).val());
55
+ if ( isNaN(val) || val < min) {
56
+ //for weird data, set slider at min
57
+ val = min;
58
+ }
59
+ var values = placeholder_input.data("slider").getValue();
60
+ values[0] = val;
61
+ placeholder_input.slider("setValue", values);
62
+ });
47
63
 
48
- end_el.change( function() {
49
- var val = parseInt($(this).val());
50
- if ( isNaN(val) || val > max ) {
51
- //weird entry, set slider to max
52
- val = max;
53
- }
54
- range_element.slider("values", 1, val+1);
55
- });
56
- }
64
+ end_el.change( function() {
65
+ var val = parseInt($(this).val());
66
+ if ( isNaN(val) || val > max ) {
67
+ //weird entry, set slider to max
68
+ val = max;
69
+ }
70
+ var values = placeholder_input.data("slider").getValue();
71
+ values[1] = val;
72
+ placeholder_input.slider("setValue", values);
73
+ });
74
+
75
+ });
76
+
77
+ // catch event for redrawing chart, to redraw slider to match width
78
+ $("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
79
+ var area = $(event.target).closest(".limit_content.range_limit");
80
+ var plot = area.find(".chart_js").data("plot");
81
+ var slider_el = area.find(".slider");
82
+
83
+ if (plot && slider_el) {
84
+ slider_el.width(plot.width());
85
+ slider_el.css("display", "block")
86
+ slider_el.css('margin-right', 'auto');
87
+ slider_el.css('margin-left', 'auto');
88
+ }
57
89
  });
58
90
 
59
91
  // returns two element array min/max as numbers. If there is a limit applied,
@@ -2,51 +2,6 @@
2
2
  * this one file, but get all our files -- and local app
3
3
  * require does not need to change if we change file list.
4
4
  *
5
+ *= require 'slider'
5
6
  *= require_tree './blacklight_range_limit'
6
7
  */
7
-
8
- .ui-slider { position: relative; text-align: left; }
9
- .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
10
- .ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
11
-
12
- .ui-slider-horizontal { height: .8em; }
13
- .ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
14
- .ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
15
- .ui-slider-horizontal .ui-slider-range-min { left: 0; }
16
- .ui-slider-horizontal .ui-slider-range-max { right: 0; }
17
-
18
- .ui-slider-vertical { width: .8em; height: 100px; }
19
- .ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
20
- .ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
21
- .ui-slider-vertical .ui-slider-range-min { bottom: 0; }
22
- .ui-slider-vertical .ui-slider-range-max { top: 0; }
23
-
24
- .ui-widget { font-family: Helvetica,Arial,sans-serif; font-size: 1.1em; }
25
- .ui-widget .ui-widget { font-size: 1em; }
26
- .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Helvetica,Arial,sans-serif; font-size: 1em; }
27
- .ui-widget-content { border: 1px solid #dddddd; background: #ffffff; color: #444444; }
28
- .ui-widget-content a { color: #444444; }
29
- .ui-widget-header { border: 1px solid #dddddd; background: #dddddd; color: #444444; font-weight: bold; }
30
- .ui-widget-header a { color: #444444; }
31
-
32
- /* Interaction states
33
- ----------------------------------*/
34
- .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #dddddd; background: #f6f6f6; font-weight: bold; color: #0073ea; }
35
- .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #0073ea; text-decoration: none; }
36
- .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #0073ea; background: #0073ea; font-weight: bold; color: #ffffff; }
37
- .ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, .ui-state-hover a:visited { color: #ffffff; text-decoration: none; }
38
- .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #dddddd; background: #ffffff; font-weight: bold; color: #ff0084; }
39
- .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ff0084; text-decoration: none; }
40
-
41
- /* Interaction Cues
42
- ----------------------------------*/
43
- .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #ffffff; color: #444444; }
44
- .ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #444444; }
45
- .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ff0084; background: #ffffff; color: #222222; }
46
- .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #222222; }
47
- .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #222222; }
48
- .ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
49
- .ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
50
- .ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
51
- .ui-state-disabled .ui-icon { filter:Alpha(Opacity=35); } /* For IE8 - See #6059 */
52
-
@@ -1,6 +1,11 @@
1
+ form.range_limit {
2
+ /* leave room for buttons not to collide on line wrap */
3
+ line-height: 3;
4
+ }
5
+
1
6
  form.range_limit input.range_begin, form.range_limit input.range_end {
2
- border:1px solid #DDDDDD;
3
- width: 4em;
7
+ display: inline-block;
8
+ width: 4.5em;
4
9
  }
5
10
 
6
11
  .limit_content .subsection {
@@ -10,3 +15,8 @@ form.range_limit input.range_begin, form.range_limit input.range_end {
10
15
  .hover_legend {
11
16
  padding: 0.25em;
12
17
  }
18
+
19
+ .slider_js .slider-selection {
20
+ /* color from flot selection */
21
+ background: #e8cfac;
22
+ }
@@ -7,7 +7,7 @@ module RangeLimitHelper
7
7
 
8
8
  default = params["range"][solr_field][type] if params["range"] && params["range"][solr_field] && params["range"][solr_field][type]
9
9
 
10
- text_field_tag("range[#{solr_field}][#{type}]", default, :maxlength=>4, :class => "range_#{type}")
10
+ text_field_tag("range[#{solr_field}][#{type}]", default, :maxlength=>4, :class => "form-control range_#{type}")
11
11
  end
12
12
 
13
13
  # type is 'min' or 'max'
@@ -82,6 +82,12 @@ module RangeLimitHelper
82
82
  my_params["range"][solr_field]["begin"] = from
83
83
  my_params["range"][solr_field]["end"] = to
84
84
  my_params["range"][solr_field].delete("missing")
85
+
86
+ # eliminate temporary range status params that were just
87
+ # for looking things up
88
+ my_params.delete("range_field")
89
+ my_params.delete("range_start")
90
+ my_params.delete("range_end")
85
91
 
86
92
  return my_params
87
93
  end
@@ -9,15 +9,24 @@
9
9
  ( (! params["range"][solr_field]["begin"].blank?) ||
10
10
  (! params["range"][solr_field]["end"].blank?) ||
11
11
  params["range"][solr_field]["missing"]) %>
12
- <div class="current">
13
- <span class="selected"><%= range_display(solr_field) %></span> <span class="count">(<%= format_num(@response.total) %>)</span> <%= link_to "[remove]", remove_range_param(solr_field), :class=>"remove" %>
14
- </div>
12
+ <ul class="current list-unstyled facet-values">
13
+ <li class="selected">
14
+ <span class="facet-label">
15
+ <span class="selected"><%= range_display(solr_field) %></span>
16
+ <%= link_to remove_range_param(solr_field), :class=>"remove", :title => "remove" do %>
17
+ <span class="glyphicon glyphicon-remove"></span>
18
+ <span class="sr-only">[remove]</span>
19
+ <% end %>
20
+ </span>
21
+ <span class="selected facet-count"><%= number_with_delimiter(@response.total) %></span>
22
+ </li>
23
+ </ul>
15
24
 
16
25
  <% end %>
17
26
 
18
27
  <% unless params["range"] && params["range"][solr_field] && params["range"][solr_field]["missing"] %>
19
28
  <%= form_tag catalog_index_path, :method => :get, :class=>"range_limit subsection range_#{solr_field} form-inline" do %>
20
- <%= search_as_hidden_fields %>
29
+ <%= render_hash_as_hidden_fields(params_for_search) %>
21
30
 
22
31
  <!-- we need to include a dummy search_field parameter if none exists,
23
32
  to trick blacklight into displaying actual search results instead
@@ -26,8 +35,8 @@
26
35
  <%= hidden_field_tag("search_field", "dummy_range") %>
27
36
  <% end %>
28
37
 
29
- <%= render_range_input(solr_field, :begin) %> - <%= render_range_input(solr_field, :end) %>
30
- <%= submit_tag 'Limit', :class=>'submit btn' %>
38
+ <%= render_range_input(solr_field, :begin) %> <%= render_range_input(solr_field, :end) %>
39
+ <%= submit_tag 'Limit', :class=>'submit btn btn-default' %>
31
40
 
32
41
  <% end %>
33
42
  <% end %>
@@ -40,9 +49,9 @@
40
49
 
41
50
  <% if (min = range_results_endpoint(solr_field, :min)) &&
42
51
  (max = range_results_endpoint(solr_field, :max)) %>
43
- <div class="range subsection <%= "slider_js" unless field_config[:slider_js] == false %>">
52
+ <p class="range subsection <%= "slider_js" unless field_config[:slider_js] == false %>">
44
53
  Current results range from <span class="min"><%= range_results_endpoint(solr_field, :min) %></span> to <span class="max"><%= range_results_endpoint(solr_field, :max) %></span>
45
- </div>
54
+ </p>
46
55
 
47
56
  <% if field_config[:segments] != false %>
48
57
  <div class="distribution subsection <%= 'chart_js' unless field_config[:chart_js] == false %>">
@@ -63,9 +72,16 @@
63
72
 
64
73
 
65
74
  <% if (stats = stats_for_field(solr_field)) && stats["missing"] > 0 %>
66
- <div class="missing subsection">
67
- <%= link_to BlacklightRangeLimit.labels[:missing], add_range_missing(solr_field) %> <%= render_facet_count(stats["missing"]) %>
68
- </div>
75
+ <ul class="missing list-unstyled facet-values subsection">
76
+ <li>
77
+ <span class="facet-label">
78
+ <%= link_to BlacklightRangeLimit.labels[:missing], add_range_missing(solr_field) %>
79
+ </span>
80
+ <span class="facet-count">
81
+ <%= number_with_delimiter(stats["missing"]) %>
82
+ </span>
83
+ </li>
84
+ </ul>
69
85
  <% end %>
70
86
  </div>
71
87
  <% end %>
@@ -1,14 +1,19 @@
1
1
  <% # must pass in local variable :solr_field
2
2
  %>
3
3
 
4
- <ul>
4
+ <ul class="facet-values list-unstyled">
5
5
  <% solr_range_queries_to_a(solr_field).each do |hash| %>
6
- <li><%= link_to(
7
- content_tag("span", hash[:from], :class => "from") +
8
- " to " +
9
- content_tag("span", hash[:to], :class => "to"),
10
- add_range(solr_field, hash[:from], hash[:to]).merge(:action => "index"),
11
- :class => "facet_select"
12
- ) %> (<%= content_tag("span", hash[:count], :class=>"count")%>)</li>
6
+ <li>
7
+ <span class="facet-label">
8
+ <%= link_to(
9
+ content_tag("span", facet_display_value(solr_field, hash[:from]), :class => "from") +
10
+ " to " +
11
+ content_tag("span", facet_display_value(solr_field, hash[:to]), :class => "to"),
12
+ add_range(solr_field, hash[:from], hash[:to]).merge(:action => "index"),
13
+ :class => "facet_select"
14
+ ) %>
15
+ </span>
16
+ <%= render_facet_count hash[:count], classes: ['count'] %>
17
+ </li>
13
18
  <% end %>
14
19
  </ul>
@@ -5,31 +5,28 @@ Gem::Specification.new do |s|
5
5
  s.name = "blacklight_range_limit"
6
6
  s.version = BlacklightRangeLimit::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Jonathan Rochkind"]
8
+ s.authors = ["Jonathan Rochkind", "Chris Beer"]
9
9
  s.email = ["blacklight-development@googlegroups.com"]
10
- s.homepage = "http://projectblacklight.org/"
10
+ s.homepage = "https://github.com/projectblacklight/blacklight_range_limit"
11
11
  s.summary = "Blacklight Range Limit plugin"
12
12
 
13
- s.rubyforge_project = "blacklight"
14
-
15
13
  s.files = `git ls-files`.split("\n")
16
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
16
  s.require_paths = ["lib"]
19
17
 
18
+ s.license = "Apache 2.0"
19
+
20
20
  s.add_dependency "rails", ">= 3.0", "< 5.0"
21
21
  s.add_dependency "jquery-rails" # our JS needs jquery_rails
22
- s.add_dependency "blacklight", "~> 4.0"
22
+ # for blacklight, we want to allow 5.0.0.preX, as well as all 5.x.y,
23
+ # but not 6. can't seem to make it do so other than this:
24
+ s.add_dependency "blacklight", ">= 5.0.0.pre4", "< 6"
23
25
 
24
- s.add_development_dependency "rspec", "~> 3.0"
26
+ s.add_development_dependency "rspec", ">= 2.0"
25
27
  s.add_development_dependency "rspec-rails"
26
28
  s.add_development_dependency "capybara"
27
29
  s.add_development_dependency "sqlite3"
28
30
  s.add_development_dependency 'launchy'
29
- s.add_development_dependency "jettywrapper"
30
- s.add_development_dependency 'engine_cart', '~> 2.0'
31
- s.add_development_dependency 'devise'
32
- s.add_development_dependency 'devise-guests'
33
- s.add_development_dependency 'bootstrap-sass'
34
- s.add_development_dependency 'turbolinks'
31
+ s.add_development_dependency "jettywrapper", "~> 1.5", ">= 1.5.2"
35
32
  end
@@ -1,4 +1,9 @@
1
- default:
1
+ development:
2
2
  startup_wait: 15
3
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
3
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
4
+ <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
5
+
6
+ test:
7
+ startup_wait: 15
8
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
4
9
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
@@ -17,16 +17,6 @@ module BlacklightRangeLimit
17
17
  helper BlacklightRangeLimit::ViewHelperOverride
18
18
  helper RangeLimitHelper
19
19
  end
20
-
21
- before_filter do |controller|
22
- unless BlacklightRangeLimit.omit_inject[:excanvas]
23
-
24
- # canvas for IE. Need to inject it like this even with asset pipeline
25
- # cause it needs IE conditional include. view_context hacky way
26
- # to get asset url helpers.
27
- controller.extra_head_content << ('<!--[if lt IE 9]>' + view_context.javascript_include_tag("flot/excanvas.min.js") + ' <![endif]-->').html_safe
28
- end
29
- end
30
20
  end
31
21
 
32
22
  # Action method of our own!
@@ -60,7 +50,7 @@ module BlacklightRangeLimit
60
50
 
61
51
  # Method added to solr_search_params_logic to fetch
62
52
  # proper things for date ranges.
63
- def add_range_limit_params(solr_params, req_params)
53
+ def add_range_limit_params(solr_params, req_params)
64
54
  ranged_facet_configs =
65
55
  blacklight_config.facet_fields.select { |key, config| config.range }
66
56
  # In ruby 1.8, hash.select returns an array of pairs, in ruby 1.9
@@ -107,8 +97,9 @@ module BlacklightRangeLimit
107
97
  # Returns range config hash for named solr field. Returns false
108
98
  # if not configured. Returns hash even if configured to 'true'
109
99
  # for consistency.
110
- def range_config(solr_field)
111
- field = blacklight_config.facet_fields[solr_field]
100
+ def range_config(solr_field)
101
+ field = blacklight_config.facet_fields[solr_field.to_s]
102
+
112
103
  return false unless field.range
113
104
 
114
105
  config = field.range
@@ -1,12 +1,29 @@
1
1
  module BlacklightRangeLimit
2
+ # This module is monkey-patch included into Blacklight::Routes, so that
3
+ # map_resource will route to catalog#range_limit, for our action
4
+ # that fetches and returns range segments -- that action is
5
+ # also monkey patched into (eg) CatalogController.
2
6
  module RouteSets
7
+ extend ActiveSupport::Concern
8
+
9
+
10
+ included do |klass|
11
+ # Have to add ours BEFORE existing,
12
+ # so catalog/range_limit can take priority over
13
+ # being considered a document ID.
14
+ klass.default_route_sets = [:range_limit] + klass.default_route_sets
15
+ end
16
+
17
+
3
18
  protected
4
- def catalog
19
+
20
+
21
+ # Add route for (eg) catalog/range_limit, pointing to the range_limit
22
+ # method we monkey patch into (eg) CatalogController.
23
+ def range_limit(primary_resource)
5
24
  add_routes do |options|
6
- get 'catalog/range_limit' => 'catalog#range_limit'
25
+ get "#{primary_resource}/range_limit" => "#{primary_resource}#range_limit"
7
26
  end
8
-
9
- super
10
27
  end
11
28
  end
12
29
  end
@@ -3,10 +3,17 @@
3
3
  # display.
4
4
  module BlacklightRangeLimit::ViewHelperOverride
5
5
 
6
- def has_range_limit_parameters?(my_params = params)
7
- my_params[:range] &&
8
- my_params[:range].any? do |key, v|
9
- v.present? && v.respond_to?(:'[]') &&
6
+
7
+
8
+ def facet_partial_name(display_facet)
9
+ return "blacklight_range_limit/range_limit_panel" if range_config(display_facet.name) and should_show_limit(display_facet.name)
10
+ super
11
+ end
12
+
13
+ def has_range_limit_parameters?(params = params)
14
+ params[:range] &&
15
+ params[:range].any? do |key, v|
16
+ v.present? && v.respond_to?(:'[]') &&
10
17
  (v["begin"].present? || v["end"].present? || v["missing"].present?)
11
18
  end
12
19
  end
@@ -16,13 +23,21 @@
16
23
  super || has_range_limit_parameters?
17
24
  end
18
25
 
19
- def query_has_constraints?(my_params = params)
20
- super(my_params) || has_range_limit_parameters?(my_params)
26
+ def query_has_constraints?(params = params)
27
+ super || has_range_limit_parameters?(params)
21
28
  end
22
29
 
23
- def facet_partial_name(display_facet)
24
- return "blacklight_range_limit/range_limit_panel" if range_config(display_facet.name) and should_show_limit(display_facet.name)
25
- super
30
+ # Over-ride to recognize our custom params for range facets
31
+ def facet_field_in_params?(field_name)
32
+ return super || (
33
+ range_config(field_name) &&
34
+ params[:range] &&
35
+ params[:range][field_name] &&
36
+ ( params[:range][field_name]["begin"].present? ||
37
+ params[:range][field_name]["end"].present? ||
38
+ params[:range][field_name]["missing"].present?
39
+ )
40
+ )
26
41
  end
27
42
 
28
43
  def render_constraints_filters(my_params = params)
@@ -30,9 +45,10 @@
30
45
  # add a constraint for ranges?
31
46
  unless my_params[:range].blank?
32
47
  my_params[:range].each_pair do |solr_field, hash|
48
+
33
49
  next unless hash["missing"] || (!hash["begin"].blank?) || (!hash["end"].blank?)
34
50
  content << render_constraint_element(
35
- facet_field_labels[solr_field],
51
+ blacklight_config.facet_fields[solr_field].label,
36
52
  range_display(solr_field, my_params),
37
53
  :escape_value => false,
38
54
  :remove => remove_range_param(solr_field, my_params)
@@ -50,7 +66,7 @@
50
66
  next unless hash["missing"] || (!hash["begin"].blank?) || (! hash["end"].blank?)
51
67
 
52
68
  content << render_search_to_s_element(
53
- facet_field_labels[solr_field],
69
+ blacklight_config.facet_fields[solr_field].label,
54
70
  range_display(solr_field, my_params),
55
71
  :escape_value => false
56
72
  )