Skip to content

Commit

Permalink
adds spatial search constraints to breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Jan 21, 2015
1 parent 99b4b76 commit 6d33443
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/geoblacklight/modules/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Blacklight.onLoad(function() {
$('#documents').replaceWith($doc.find('#documents'));
$('#sidebar').replaceWith($doc.find('#sidebar'));
$('#sortAndPerPage').replaceWith($doc.find('#sortAndPerPage'));
$('#appliedParams').replaceWith($doc.find('#appliedParams'));
if ($('#map').next().length) {
$('#map').next().replaceWith($doc.find('#map').next());
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/geoblacklight.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "geoblacklight/engine"

module Geoblacklight
require 'geoblacklight/catalog_helper_override'
require 'geoblacklight/config'
require 'geoblacklight/constants'
require 'geoblacklight/controller_override'
Expand All @@ -20,6 +21,7 @@ module Geoblacklight
require 'geoblacklight/references'
def self.inject!
CatalogController.send(:include, Geoblacklight::ControllerOverride)
CatalogController.send(:include, Geoblacklight::CatalogHelperOverride)
CatalogController.send(:include, Geoblacklight::ViewHelperOverride)
CatalogController.send(:helper, Geoblacklight::ViewHelperOverride) unless
CatalogController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
Expand Down
14 changes: 14 additions & 0 deletions lib/geoblacklight/catalog_helper_override.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Geoblacklight
module CatalogHelperOverride

##
# Removes spatial query from params
# @param [Symbol] symbol of field to be removed
# @param [Hash] request parameters
def remove_spatial_filter_group(field, source_params = params)
p = source_params.dup
p.delete(field.to_s)
p
end
end
end
20 changes: 17 additions & 3 deletions lib/geoblacklight/view_helper_override.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
module Geoblacklight
module ViewHelperOverride
def has_spatial_parameters?
include CatalogHelperOverride

def spatial_parameters?
params[:bbox]
end

# Overrides BL method to enable results for spatial only params
def has_search_parameters?
has_spatial_parameters? || super
spatial_parameters? || super
end

def query_has_contraints?(params = params)
def query_has_constraints?(params = params)
has_search_parameters? || super
end

Expand All @@ -21,5 +23,17 @@ def render_search_to_s_bbox(params)
return ''.html_safe if params['bbox'].blank?
render_search_to_s_element('Bounding box', render_filter_value(params['bbox']) )
end

def render_constraints_filters(params = params)
content = super(params)

if params[:bbox]
content << render_constraint_element('Bounding Box',
params[:bbox],
remove: catalog_index_path(remove_spatial_filter_group(:bbox, params)))
end

return content
end
end
end
1 change: 1 addition & 0 deletions spec/features/split_view.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
within '#appliedParams' do
expect(page).to have_content('Subject polygon')
expect(page).to have_content('Subject boundaries')
expect(page).to have_css 'span.filterName', text: 'Bounding Box'
end
end
end
10 changes: 5 additions & 5 deletions spec/lib/geoblacklight/view_helper_override_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
class GeoblacklightControllerTestClass
attr_accessor :params
end

before(:each) do
@fake_controller = GeoblacklightControllerTestClass.new
@fake_controller.extend(Geoblacklight::ViewHelperOverride)
end
describe 'has_spatial_parameters?' do

describe 'spatial_parameters?' do
it 'should not have spatial parameters' do
@fake_controller.params = {}
expect(@fake_controller.has_spatial_parameters?).to be_falsey
expect(@fake_controller.spatial_parameters?).to be_falsey
end
it 'should have spatial parameters' do
@fake_controller.params = { bbox: '123'}
expect(@fake_controller.has_spatial_parameters?).to be_truthy
expect(@fake_controller.spatial_parameters?).to be_truthy
end
end
describe 'render_search_to_s_bbox' do
Expand Down

0 comments on commit 6d33443

Please sign in to comment.