Module: BlacklightRangeLimit::ControllerOverride

Extended by:
ActiveSupport::Concern
Defined in:
lib/blacklight_range_limit/controller_override.rb

Instance Method Summary collapse

Instance Method Details

#has_range_limit_parameters?(my_params = params) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
41
42
43
# File 'lib/blacklight_range_limit/controller_override.rb', line 37

def has_range_limit_parameters?(my_params = params)
  my_params[:range] &&
    my_params[:range].to_unsafe_h.any? do |key, v|
      v.present? && v.respond_to?(:'[]') &&
      (v["begin"].present? || v["end"].present? || v["missing"].present?)
    end
end

#has_search_parameters?Boolean

over-ride, call super, but make sure our range limits count too

Returns:

  • (Boolean)

33
34
35
# File 'lib/blacklight_range_limit/controller_override.rb', line 33

def has_search_parameters?
  super || has_range_limit_parameters?
end

#range_limitObject

Action method of our own! Delivers a partial that's a display of a single fields range facets. Used when we need a second Solr query to get range facets, after the first found min/max from result set.


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/blacklight_range_limit/controller_override.rb', line 19

def range_limit
  # We need to swap out the add_range_limit_params search param filter,
  # and instead add in our fetch_specific_range_limit filter,
  # to fetch only the range limit segments for only specific
  # field (with start/end params) mentioned in query params
  # range_field, range_start, and range_end

  @response, _ = search_service.search_results do |search_builder|
    search_builder.except(:add_range_limit_params).append(:fetch_specific_range_limit)
  end
  render('blacklight_range_limit/range_segments', :locals => {:solr_field => params[:range_field]}, :layout => !request.xhr?)
end

#range_limit_panelObject

Raises:

  • (ActionController::RoutingError)

45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/blacklight_range_limit/controller_override.rb', line 45

def range_limit_panel
  @facet = blacklight_config.facet_fields[params[:id]]
  raise ActionController::RoutingError, 'Not Found' unless @facet

  @response = search_service.search_results.first

  respond_to do |format|
    format.html do
      # Draw the partial for the "more" facet modal window:
      return render 'blacklight_range_limit/range_limit_panel', layout: !request.xhr?
    end
  end
end