Module: BlacklightMaps::RenderConstraintsOverride
- Defined in:
- lib/blacklight/maps/render_constraints_override.rb
Instance Method Summary collapse
- #has_spatial_parameters?(search_state) ⇒ Boolean
-
#query_has_constraints?(params_or_search_state = search_state) ⇒ Boolean
BlacklightMaps override: check for coordinate parameters.
-
#remove_spatial_params(search_state) ⇒ String
remove the spatial params from params.
-
#render_constraints(localized_params = params, local_search_state = search_state) ⇒ String
BlacklightMaps override: include render_spatial_query() in rendered constraints.
-
#render_search_to_s(params) ⇒ String
BlacklightMaps override: include render_search_to_s_coord() in rendered constraints Simpler textual version of constraints, used on Search History page.
-
#render_search_to_s_coord(params) ⇒ String
Render the search query constraint.
-
#render_spatial_query(params_or_search_state = search_state) ⇒ String
Render the spatial query constraints.
-
#spatial_constraint_label(params_or_search_state) ⇒ String
render the label for the spatial constraint.
Instance Method Details
#has_spatial_parameters?(search_state) ⇒ Boolean
10 11 12 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 10 def has_spatial_parameters?(search_state) search_state.params[:coordinates].present? end |
#query_has_constraints?(params_or_search_state = search_state) ⇒ Boolean
BlacklightMaps override: check for coordinate parameters
17 18 19 20 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 17 def query_has_constraints?(params_or_search_state = search_state) search_state = convert_to_search_state(params_or_search_state) has_spatial_parameters?(search_state) || super end |
#remove_spatial_params(search_state) ⇒ String
remove the spatial params from params
74 75 76 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 74 def remove_spatial_params(search_state) search_action_path(search_state.params.dup.except!(:coordinates, :spatial_search_type)) end |
#render_constraints(localized_params = params, local_search_state = search_state) ⇒ String
BlacklightMaps override: include render_spatial_query() in rendered constraints
26 27 28 29 30 31 32 33 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 26 def render_constraints(localized_params = params, local_search_state = search_state) params_or_search_state = if localized_params != params localized_params else local_search_state end render_spatial_query(params_or_search_state) + super end |
#render_search_to_s(params) ⇒ String
BlacklightMaps override: include render_search_to_s_coord() in rendered constraints Simpler textual version of constraints, used on Search History page.
39 40 41 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 39 def render_search_to_s(params) render_search_to_s_coord(params) + super end |
#render_search_to_s_coord(params) ⇒ String
Render the search query constraint
47 48 49 50 51 52 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 47 def render_search_to_s_coord(params) return ''.html_safe if params[:coordinates].blank? render_search_to_s_element(spatial_constraint_label(params), render_filter_value(params[:coordinates])) end |
#render_spatial_query(params_or_search_state = search_state) ⇒ String
Render the spatial query constraints
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 57 def render_spatial_query(params_or_search_state = search_state) search_state = convert_to_search_state(params_or_search_state) # So simple don't need a view template, we can just do it here. return ''.html_safe if search_state.params[:coordinates].blank? render_constraint_element(spatial_constraint_label(search_state), search_state.params[:coordinates], classes: ['coordinates'], remove: remove_spatial_params(search_state)) # _params.except!(:coordinates, :spatial_search_type) end |
#spatial_constraint_label(params_or_search_state) ⇒ String
render the label for the spatial constraint
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/blacklight/maps/render_constraints_override.rb', line 82 def spatial_constraint_label(params_or_search_state) search_params = if params_or_search_state.is_a?(Blacklight::SearchState) params_or_search_state.params else params_or_search_state end if search_params[:spatial_search_type] && search_params[:spatial_search_type] == 'bbox' t('blacklight.search.filters.coordinates.bbox') else t('blacklight.search.filters.coordinates.point') end end |