Skip to content

Commit

Permalink
Use presenters to deliver the document url and title
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jan 13, 2020
1 parent 9837fc1 commit 6ca5b2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 2 additions & 10 deletions app/helpers/blacklight/maps_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def sidebar_template
<div class='media'>
<div class='media-body'>
<h3 class='media-heading'>
<a href=\"#{document_path}\"}>
{#{blacklight_config.index.title_field}}
<a href=\"{url}\"}>
{title}
</a>
</h3>
</div>
Expand All @@ -34,14 +34,6 @@ def sidebar_template

private

##
# Document path used for creating client side links to documents from a
# template
# @return String
def document_path
"#{search_catalog_path}/{#{blacklight_config.document_unique_id_param}}"
end

##
# Data attributes used in displaying the index map
# @return Hash
Expand Down
5 changes: 5 additions & 0 deletions app/views/catalog/index.heatmaps.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
presenter = Blacklight::JsonPresenter.new(@response, blacklight_config)

json.response do
json.docs(presenter.documents) do |document|
json.url polymorphic_url(url_for_document(document))
json.title index_presenter(document).heading
end

json.facet_heatmaps @response['facet_counts']['facet_heatmaps']
json.pages presenter.pagination_info
end
2 changes: 1 addition & 1 deletion spec/helpers/blacklight/maps_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
describe '#sidebar_template' do
it 'renders html template used in sidebar' do
expect(helper.sidebar_template)
.to have_css '.media .media-body h3.media-heading a', text: '{title_display}'
.to have_css '.media .media-body h3.media-heading a', text: '{title}'
end
end
end

0 comments on commit 6ca5b2e

Please sign in to comment.