-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
link relatedItem[@otherType] values to facet if configured (DLC-1144)
- replace deprecated field configuration key link_to_search with link_to_facet
- Loading branch information
Showing
15 changed files
with
73 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Dcv | ||
module Rendering | ||
class LinkToFacet < Blacklight::Rendering::LinkToFacet | ||
def render | ||
return next_step(values) unless linkable_facet | ||
|
||
next_step(render_link) | ||
end | ||
|
||
def linkable_facet | ||
config.link_to_facet && context.blacklight_config.facet_fields[link_field] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'rails_helper' | ||
|
||
describe Dcv::FieldPresenter do | ||
include_context "a solr document" | ||
|
||
let(:blacklight_config) { Blacklight::Configuration.new } | ||
let(:search_action_path) { '/search' } | ||
let(:search_state) { Dcv::SearchState.new({}, blacklight_config) } | ||
let(:view_context) { double(ActionController::Base, blacklight_config: blacklight_config, search_state: search_state, search_action_path: search_action_path) } | ||
let(:presenter) { described_class.new(view_context, solr_document, blacklight_config.show_fields['dc_type_ssm']) } | ||
|
||
before do | ||
blacklight_config.add_show_field 'dc_type_ssm', label: 'DcType', link_to_facet: true | ||
end | ||
|
||
it "does not link the values without a configured facet" do | ||
expect(presenter.render).to eql "Unknown" | ||
end | ||
|
||
context "facet field is configured" do | ||
before do | ||
blacklight_config.add_facet_field 'dc_type_ssm', label: 'DcType' | ||
allow(view_context).to receive(:link_to).and_return ('success') | ||
end | ||
|
||
it "links the values" do | ||
expect(presenter.render).to eql "success" | ||
end | ||
end | ||
end |