From 943b01de1bc15dbab76f80e8b9392f80798f0fda Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Fri, 14 Jul 2017 14:40:04 -0700 Subject: [PATCH 1/8] Add a HooverOpenUrlRequest class to build the url for Hoover Aeon links. --- app/models/hoover_open_url_request.rb | 116 ++++++++++ config/settings.yml | 1 + .../marc_records/marc_metadata_fixtures.rb | 32 +++ spec/models/hoover_open_url_requst_spec.rb | 201 ++++++++++++++++++ 4 files changed, 350 insertions(+) create mode 100644 app/models/hoover_open_url_request.rb create mode 100644 spec/models/hoover_open_url_requst_spec.rb diff --git a/app/models/hoover_open_url_request.rb b/app/models/hoover_open_url_request.rb new file mode 100644 index 000000000..1baedee73 --- /dev/null +++ b/app/models/hoover_open_url_request.rb @@ -0,0 +1,116 @@ +class HooverOpenUrlRequest + delegate :to_param, to: :as_params + delegate :safe_join, :solr_document_url, to: :view_context + def initialize(library, document, view_context) + @library = library + @document = document + @view_context = view_context + end + + def to_url + "#{base_url}&#{to_param}" + end + + def as_params + { + 'ItemInfo5' => record_url, 'ReferenceNumber' => ckey, + 'ItemTitle' => item_title, 'ItemAuthor' => item_author, + 'ItemDate' => item_date, 'ItemPublisher' => item_publisher, + 'ItemPlace' => item_place, 'ItemEdition' => item_edition, + 'ItemInfo2' => item_restrictions, 'ItemInfo3' => item_conditions, + 'Value' => request_type + }.reject { |_, v| v.blank? } + end + + def request_type + return 'GenericRequestManuscript' if archive? + 'GenericRequestMonograph' + end + + def record_url + solr_document_url(document) + end + + def ckey + document[:id] + end + + def item_title + marc_data(field_codes: '245', subfield_codes: %w[a b n p]) + end + + def item_author + author_fields = { + '100' => %w[a b c d q], '110' => %w[a b c d], + '111' => %w[a c d], '130' => %w[a d f n p] + } + + author_fields.each do |field_codes, subfield_codes| + data = marc_data(field_codes: field_codes, subfield_codes: subfield_codes) + return data if data.present? + end + nil # return nil if none of the fields matched + end + + def item_date + return unless archive? + marc_data(field_codes: '245', subfield_codes: ['f']) + end + + def item_publisher + return if archive? + marc_260 = marc_data(field_codes: '260', subfield_codes: %w[a b c]) + marc_264 = marc_data(field_codes: '264', subfield_codes: %w[a b c]) + safe_join([marc_260, marc_264], ' ') + end + + def item_place + marc_data(field_codes: '300', subfield_codes: %w[a b c f]) + end + + def item_edition + return if archive? + marc_data(field_codes: '250', subfield_codes: ['a']) + end + + def item_restrictions + marc_data(field_codes: '506', subfield_codes: %w[3 a]) + end + + def item_conditions + return unless archive? + marc_data(field_codes: '540', subfield_codes: %w[3 a]) + end + + private + + attr_reader :library, :document, :view_context + + def archive? + library == 'HV-ARCHIVE' + end + + def marc + document.to_marc + end + + def marc_data(field_codes:, subfield_codes:) + field_code = marc_field_code_for_present_data(field_codes: field_codes, subfield_codes: subfield_codes) + return unless field_code + + safe_join(marc[field_code].subfields.map do |subfield| + next unless subfield_codes.include?(subfield.code) + subfield.value + end.compact, ' ') + end + + def marc_field_code_for_present_data(field_codes:, subfield_codes:) + Array.wrap(field_codes).find do |code| + marc[code].present? && marc[code].subfields.any? { |subfield| subfield_codes.include?(subfield.code) } + end + end + + def base_url + Settings.HOOVER_REQUESTS_URL + end +end diff --git a/config/settings.yml b/config/settings.yml index dd6db2c5d..2424130c8 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -6,6 +6,7 @@ HOSTNAME: <%= (`echo $HOSTNAME`).gsub('.stanford.edu', '') %> STACKS_URL: "https://stacks.stanford.edu/image" REQUESTS_URL: "https://host.example.com/requests/new" SSRC_REQUESTS_URL: "http://host.example.com/link.ssds_request_form" +HOOVER_REQUESTS_URL: 'https://hoover.aeon.atlas-sys.com/aeon.dll?Action=10&Form=20' LIVE_LOOKUP_URL: "http://host.example.com/lookup.pl" STACKMAP_API_URL: "https://stanford.stackmap.com/json/" WHEN_TO_PRUNE_DATA: '12:30am' diff --git a/spec/fixtures/marc_records/marc_metadata_fixtures.rb b/spec/fixtures/marc_records/marc_metadata_fixtures.rb index bf90729ac..db1d9741b 100644 --- a/spec/fixtures/marc_records/marc_metadata_fixtures.rb +++ b/spec/fixtures/marc_records/marc_metadata_fixtures.rb @@ -1182,4 +1182,36 @@ def linked_related_works_fixture xml end + + def hoover_request_fixture + <<-xml + + + 100 Subfield $a + + + 245 Subfield $f + + + 250 Subfield $a + + + 260 Subfield $a + 260 Subfield $b + 260 Subfield $c + + + 264 Subfield $c + + + 506 Subfield $3 + 506 Subfield $a + + + 540 Subfield $3 + 540 Subfield $a + + + xml + end end diff --git a/spec/models/hoover_open_url_requst_spec.rb b/spec/models/hoover_open_url_requst_spec.rb new file mode 100644 index 000000000..2f0ae3999 --- /dev/null +++ b/spec/models/hoover_open_url_requst_spec.rb @@ -0,0 +1,201 @@ +require 'spec_helper' + +describe HooverOpenUrlRequest do + include MarcMetadataFixtures + + subject(:url) { described_class.new(library, document, view_context) } + + let(:library) { 'HOOVER' } + let(:view_context) do + Class.new do + include Rails.application.routes.url_helpers + include ActionView::Helpers::OutputSafetyHelper + end.new + end + let(:marcxml) { metadata1 } + let(:document) do + SolrDocument.new( + id: 'abc123', + marcxml: marcxml + ) + end + + before do + allow(Rails.application.routes).to receive_messages(default_url_options: { host: 'example.com' }) + end + + describe '#to_url' do + it 'joins the configured base url and the params hash as a query string' do + expect(url.to_url).to match(/aeon\.dll\?Action=10&Form=20&ItemAuthor=Arbitrary/) + end + end + + describe '#to_param' do + it 'is delegated to the params hash' do + expect(url.to_param).to match(/&ReferenceNumber=abc123&Value=GenericRequestMonograph/) + end + end + + describe 'as_params' do + it 'is a hash' do + expect(url.as_params).to be_a Hash + end + + describe 'hash keys' do + let(:marcxml) { hoover_request_fixture } + + it 'has keys generic to both libraries' do + expect(url.as_params.keys).to include 'ItemInfo5' + expect(url.as_params.keys).to include 'ReferenceNumber' + expect(url.as_params.keys).to include 'ItemAuthor' + expect(url.as_params.keys).to include 'Value' + end + + context 'for HOOVER' do + it 'includes keys that are specific to hoover' do + expect(url.as_params.keys).to include 'ItemEdition' + expect(url.as_params.keys).to include 'ItemPublisher' + end + + it 'does not include keys that are specific to the archive' do + expect(url.as_params.keys).not_to include 'ItemInfo3' + expect(url.as_params.keys).not_to include 'ItemDate' + end + end + + context 'for HV-ARCHIVE' do + let(:library) { 'HV-ARCHIVE' } + + it 'includes keys that are specific to the archive' do + expect(url.as_params.keys).to include 'ItemInfo3' + expect(url.as_params.keys).to include 'ItemDate' + end + + it 'does not include keys that are specific to hoover' do + expect(url.as_params.keys).not_to include 'ItemEdition' + expect(url.as_params.keys).not_to include 'ItemPublisher' + end + end + end + end + + context 'Non library-specific' do + describe '#record_url' do + it 'returns the solr document url from the view context' do + expect(url.record_url).to eq 'http://example.com/view/abc123' + end + end + + describe '#ckey' do + it 'returns the document id' do + expect(url.ckey).to eq document[:id] + end + end + + describe '#item_title' do + it 'returns data from the 245' do + expect(url.item_title).to eq 'Some intersting papers,' + end + end + + describe '#item_author' do + context 'with multiple authors' do + it 'returns the first author data' do + expect(url.item_author).to eq 'Arbitrary, Stewart.' + end + end + + context 'with a single author' do + let(:marcxml) { linked_author_meeting_fixture } + + it 'returns authors later in the metadata when earlier is not present' do + expect(url.item_author).to eq 'Technical Workshop on Organic Agriculture 2010 : Ogbomoso, Nigeria)' + end + end + + context 'with no author' do + let(:marcxml) { related_works_fixture } + + it 'returns nil' do + expect(url.item_author).to be_nil + end + end + end + + describe '#item_restrictions' do + let(:marcxml) { hoover_request_fixture } + + it 'returns 506$3$a' do + expect(url.item_restrictions).to eq '506 Subfield $3 506 Subfield $a' + end + end + + describe '#item_place' do + it 'returns data from the 300 field' do + expect(url.item_place).to match(/^53 linear feet/) + end + end + end + + context 'Hoover Library' do + describe '#request_type' do + it { expect(url.request_type).to eq 'GenericRequestMonograph' } + end + + describe '#item_publisher' do + let(:marcxml) { hoover_request_fixture } + + it 'it returns subfields $a, $b, $c 260/264' do + expect(url.item_publisher).to eq '260 Subfield $a 260 Subfield $b 260 Subfield $c 264 Subfield $c' + end + end + + describe '#item_edition' do + let(:marcxml) { hoover_request_fixture } + + it 'returns data from the 250$a' do + expect(url.item_edition).to eq '250 Subfield $a' + end + end + + describe '#item_conditions' do + let(:marcxml) { hoover_request_fixture } + + it { expect(url.item_conditions).to be_nil } + end + end + + context 'Hoover Archive' do + let(:library) { 'HV-ARCHIVE' } + + describe '#request_type' do + it { expect(url.request_type).to eq 'GenericRequestManuscript' } + end + + describe '#item_date' do + let(:marcxml) { hoover_request_fixture } + + it 'returns 245$f' do + expect(url.item_date).to eq '245 Subfield $f' + end + end + + describe '#item_publisher' do + it { expect(url.item_publisher).to be_nil } + end + + describe '#item_edition' do + let(:marcxml) { edition_imprint_fixture } + + it { expect(url.item_edition).to be_nil } + end + + describe '#item_conditions' do + let(:marcxml) { hoover_request_fixture } + + it 'returns 540$3$a' do + expect(url.item_conditions).to eq '540 Subfield $3 540 Subfield $a' + end + end + end +end From a596baae4ef8c888756395351d2d9f6055a5b9da Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Tue, 18 Jul 2017 09:46:39 -0700 Subject: [PATCH 2/8] UI updates to support Hoover/Aeon Linking --- app/helpers/request_link_helper.rb | 5 ++ app/views/catalog/_index_location.html.erb | 54 ++++++++++++---------- lib/constants.rb | 5 +- spec/features/request_link_spec.rb | 25 ++++++++++ spec/fixtures/solr_documents/56.yml | 7 +++ spec/helpers/request_link_helper_spec.rb | 18 ++++++++ 6 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 spec/features/request_link_spec.rb create mode 100644 spec/fixtures/solr_documents/56.yml diff --git a/app/helpers/request_link_helper.rb b/app/helpers/request_link_helper.rb index 3261bf32c..bcbcf9a32 100644 --- a/app/helpers/request_link_helper.rb +++ b/app/helpers/request_link_helper.rb @@ -12,6 +12,7 @@ def link_to_request_link(options = {}) def request_link(document, callnumber, barcode = nil) return unless callnumber + return hoover_request_url(document, callnumber) if Constants::HOOVER_LIBS.include?(callnumber.library) if callnumber.home_location == 'SSRC-DATA' base_url = Settings.SSRC_REQUESTS_URL request_params = ssrc_params(document, callnumber) @@ -24,6 +25,10 @@ def request_link(document, callnumber, barcode = nil) private + def hoover_request_url(document, callnumber) + HooverOpenUrlRequest.new(callnumber.library, document, self).to_url + end + def process_request_params(document, callnumber, barcode) request_params = request_options(document, callnumber) request_params[:barcode] = barcode if barcode diff --git a/app/views/catalog/_index_location.html.erb b/app/views/catalog/_index_location.html.erb index db81131be..60e7cf4d2 100644 --- a/app/views/catalog/_index_location.html.erb +++ b/app/views/catalog/_index_location.html.erb @@ -31,37 +31,43 @@ <% end %> <% end %> <% if location.items.present? && !location.bound_with? %> - <% if location_level_request_link?(library, location) %> + <% if location_level_request_link?(library, location) && !Constants::HOOVER_LIBS.include?(library.code) %> <%= link_to_request_link(document: document, library: library, callnumber: location.items.first, class: 'btn btn-default btn-xs request-button') %> <% end %> <% end %> - <% location.items.each do |item| %> + <% if Constants::HOOVER_LIBS.include?(library.code) %> - - <%= item.callnumber %> - - > - - - <%= item.status.status_text %> - - - <% unless item.treat_current_location_as_home_location? %> - <%= item.current_location.name %> - <% end %> - - <% if item.on_reserve? %> - <%= item.loan_period %> - <% end %> - - <% if item.must_request? %> - <%= link_to_request_link(document: document, library: library, callnumber: item, barcode: item.barcode, class: 'btn btn-default request-button btn-xs') %> - <% end %> - - + <%= link_to('See full record for details', solr_document_path(document)) %> + <% else %> + <% location.items.each do |item| %> + + + <%= item.callnumber %> + + > + + + <%= item.status.status_text %> + + + <% unless item.treat_current_location_as_home_location? %> + <%= item.current_location.name %> + <% end %> + + <% if item.on_reserve? %> + <%= item.loan_period %> + <% end %> + + <% if item.must_request? %> + <%= link_to_request_link(document: document, library: library, callnumber: item, barcode: item.barcode, class: 'btn btn-default request-button btn-xs') %> + <% end %> + + + + <% end %> <% end %> <% end %> diff --git a/lib/constants.rb b/lib/constants.rb index da6bf0927..c8075d1e2 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -845,16 +845,19 @@ module Constants 'TECH-SERV', 'TEMP-LL'] - REQUEST_LIBS = ['MEDIA-MTXT', 'RUMSEYMAP', 'SAL', 'SAL3', 'SAL-NEWARK', 'SPEC-COLL'].freeze + REQUEST_LIBS = ['HOOVER', 'HV-ARCHIVE', 'MEDIA-MTXT', 'RUMSEYMAP', 'SAL', 'SAL3', 'SAL-NEWARK', 'SPEC-COLL'].freeze LOCATION_LEVEL_REQUEST_LOCS = ['SSRC-DATA'] REQUEST_ON_SITE_ACCESS_LIBS = [ + 'HOOVER', 'HV-ARCHIVE', 'RUMSEYMAP', 'SPEC-COLL' ].freeze + HOOVER_LIBS = %w[HOOVER HV-ARCHIVE].freeze + REQUEST_LOCS = ['GUNST-30', 'FELTON-30', 'RBC-30', diff --git a/spec/features/request_link_spec.rb b/spec/features/request_link_spec.rb new file mode 100644 index 000000000..739f9a467 --- /dev/null +++ b/spec/features/request_link_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'Request Links', type: :feature do + describe 'Hoover links' do + context 'in search results' do + it 'renders a link to the detail/record view instead of holdings' do + visit search_catalog_path(q: '56') + + within 'table.availability' do + expect(page).not_to have_content 'ABC 123' + + expect(page).to have_link 'See full record for details' + end + end + end + + context 'on the record view' do + it 'renders a request button at the location level' do + visit solr_document_path '56' + + expect(page).to have_css('.request-button', text: 'Request on-site access') + end + end + end +end diff --git a/spec/fixtures/solr_documents/56.yml b/spec/fixtures/solr_documents/56.yml new file mode 100644 index 000000000..858cc9dac --- /dev/null +++ b/spec/fixtures/solr_documents/56.yml @@ -0,0 +1,7 @@ +:id: 56 +:title_display: Hoover Item +:format_main_ssim: Map +:marcxml: <%= hoover_request_fixture %> +:marcbib_xml: <%= hoover_request_fixture %> +:item_display: + - "123 -|- HOOVER -|- STACKS -|- -|- -|- -|- -|- -|- ABC 123" diff --git a/spec/helpers/request_link_helper_spec.rb b/spec/helpers/request_link_helper_spec.rb index b4232bafa..821c6c410 100644 --- a/spec/helpers/request_link_helper_spec.rb +++ b/spec/helpers/request_link_helper_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe RequestLinkHelper do + include MarcMetadataFixtures + let(:current_location_document) do SolrDocument.new( id: '1234', @@ -69,6 +71,22 @@ end end + describe 'Hoover Library/Archive' do + let(:hoover_doc) do + SolrDocument.new( + id: '1234', + marcxml: hoover_request_fixture, + item_display: ['9876 -|- HOOVER -|- STACKS -|- -|- -|- -|- -|- -|- ABC 123'] + ) + end + + it "returns the OpenURL link for Hoover's request system" do + link = helper.request_link(hoover_doc, hoover_doc.holdings.callnumbers.first) + + expect(link).to match(/^#{Regexp.escape(Settings.HOOVER_REQUESTS_URL)}/) + end + end + describe 'SSRC-DATA' do let(:ssrc_document) do SolrDocument.new( From 18e115241f9569e81c46ae9661ef6fd7e397cd38 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Mon, 24 Jul 2017 11:58:52 -0700 Subject: [PATCH 3/8] Update request link text to use i18n to faciltate changing request link wording per-library. --- app/helpers/request_link_helper.rb | 9 ++++----- config/locales/searchworks.en.yml | 6 ++++++ lib/constants.rb | 7 ------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/helpers/request_link_helper.rb b/app/helpers/request_link_helper.rb index bcbcf9a32..c31e266ff 100644 --- a/app/helpers/request_link_helper.rb +++ b/app/helpers/request_link_helper.rb @@ -2,11 +2,10 @@ module RequestLinkHelper def link_to_request_link(options = {}) url = request_link(options[:document], options[:callnumber], options[:barcode]) return unless url - link_text = if Constants::REQUEST_ON_SITE_ACCESS_LIBS.include?(options[:library].try(:code)) - 'Request on-site access' - else - 'Request' - end + link_text = t( + "searchworks.request_link.#{options[:library].try(:code) || 'default'}", + default: :'searchworks.request_link.default' + ) link_to(link_text, url, rel: 'nofollow', class: options[:class], data: { behavior: 'requests-modal' }) end diff --git a/config/locales/searchworks.en.yml b/config/locales/searchworks.en.yml index e76d1304e..0e3e211f1 100644 --- a/config/locales/searchworks.en.yml +++ b/config/locales/searchworks.en.yml @@ -63,6 +63,12 @@ en: label: Series default: label: 'Field' + request_link: + default: Request + HOOVER: Request on-site access + HV-ARCHIVE: Request on-site access + RUMSEYMAP: Request on-site access + SPEC-COLL: Request on-site access blacklight: course_reserves: page_title: "Course reserves in %{application_name}" diff --git a/lib/constants.rb b/lib/constants.rb index c8075d1e2..7715a38f8 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -849,13 +849,6 @@ module Constants LOCATION_LEVEL_REQUEST_LOCS = ['SSRC-DATA'] - REQUEST_ON_SITE_ACCESS_LIBS = [ - 'HOOVER', - 'HV-ARCHIVE', - 'RUMSEYMAP', - 'SPEC-COLL' - ].freeze - HOOVER_LIBS = %w[HOOVER HV-ARCHIVE].freeze REQUEST_LOCS = ['GUNST-30', From 0ec475bf274c63d6860c19b9c0c3a0bd62e760f0 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Tue, 25 Jul 2017 11:39:03 -0700 Subject: [PATCH 4/8] Do not put requess-modal data attribute on hoover links. --- app/helpers/request_link_helper.rb | 8 +++++++- spec/helpers/request_link_helper_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/helpers/request_link_helper.rb b/app/helpers/request_link_helper.rb index c31e266ff..bd556e744 100644 --- a/app/helpers/request_link_helper.rb +++ b/app/helpers/request_link_helper.rb @@ -6,7 +6,7 @@ def link_to_request_link(options = {}) "searchworks.request_link.#{options[:library].try(:code) || 'default'}", default: :'searchworks.request_link.default' ) - link_to(link_text, url, rel: 'nofollow', class: options[:class], data: { behavior: 'requests-modal' }) + link_to(link_text, url, rel: 'nofollow', class: options[:class], data: link_data_attributes(options[:callnumber])) end def request_link(document, callnumber, barcode = nil) @@ -24,6 +24,12 @@ def request_link(document, callnumber, barcode = nil) private + def link_data_attributes(callnumber) + return {} if Constants::HOOVER_LIBS.include?(callnumber.library) + + { behavior: 'requests-modal' } + end + def hoover_request_url(document, callnumber) HooverOpenUrlRequest.new(callnumber.library, document, self).to_url end diff --git a/spec/helpers/request_link_helper_spec.rb b/spec/helpers/request_link_helper_spec.rb index 821c6c410..b68ff2cc6 100644 --- a/spec/helpers/request_link_helper_spec.rb +++ b/spec/helpers/request_link_helper_spec.rb @@ -3,6 +3,14 @@ describe RequestLinkHelper do include MarcMetadataFixtures + let(:hoover_document) do + SolrDocument.new( + id: '1234', + marcxml: hoover_request_fixture, + item_display: ['barcode -|- HOOVER -|- home_location -|- current_location -|- type -|- truncated_callnumber -|- shelfkey -|- reverse_shelfkey -|- callnumber'] + ) + end + let(:current_location_document) do SolrDocument.new( id: '1234', @@ -37,6 +45,22 @@ expect(Capybara.string(link)).to have_link('Request on-site access') end + + it 'has has the requests-modal attribute for non-hoover items' do + link = link_to_request_link( + document: current_location_document, callnumber: current_location_document.holdings.callnumbers.first + ) + + expect(Capybara.string(link)).to have_css('a[data-behavior="requests-modal"]') + end + + it 'has does not have requests-modal attribute for hoover items' do + link = link_to_request_link( + document: hoover_document, callnumber: hoover_document.holdings.callnumbers.first + ) + + expect(Capybara.string(link)).not_to have_css('a[data-behavior="requests-modal"]') + end end describe '#request_link' do From 809a4a3b41e0cb13a8bd0687ca6afd15fac4fb53 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Fri, 11 Aug 2017 10:41:19 -0700 Subject: [PATCH 5/8] Make hoover request links open in a new tab. --- app/helpers/request_link_helper.rb | 14 +++++++++++++- spec/helpers/request_link_helper_spec.rb | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/helpers/request_link_helper.rb b/app/helpers/request_link_helper.rb index bd556e744..b46457b9a 100644 --- a/app/helpers/request_link_helper.rb +++ b/app/helpers/request_link_helper.rb @@ -6,7 +6,14 @@ def link_to_request_link(options = {}) "searchworks.request_link.#{options[:library].try(:code) || 'default'}", default: :'searchworks.request_link.default' ) - link_to(link_text, url, rel: 'nofollow', class: options[:class], data: link_data_attributes(options[:callnumber])) + link_to( + link_text, + url, + target: request_link_target(options[:callnumber]), + rel: 'nofollow', + class: options[:class], + data: link_data_attributes(options[:callnumber]) + ) end def request_link(document, callnumber, barcode = nil) @@ -24,6 +31,11 @@ def request_link(document, callnumber, barcode = nil) private + def request_link_target(callnumber) + return unless callnumber && Constants::HOOVER_LIBS.include?(callnumber.library) + '_blank' + end + def link_data_attributes(callnumber) return {} if Constants::HOOVER_LIBS.include?(callnumber.library) diff --git a/spec/helpers/request_link_helper_spec.rb b/spec/helpers/request_link_helper_spec.rb index b68ff2cc6..92f904b87 100644 --- a/spec/helpers/request_link_helper_spec.rb +++ b/spec/helpers/request_link_helper_spec.rb @@ -54,12 +54,20 @@ expect(Capybara.string(link)).to have_css('a[data-behavior="requests-modal"]') end - it 'has does not have requests-modal attribute for hoover items' do - link = link_to_request_link( - document: hoover_document, callnumber: hoover_document.holdings.callnumbers.first - ) + describe 'Hoover links' do + let(:link) do + Capybara.string( + link_to_request_link(document: hoover_document, callnumber: hoover_document.holdings.callnumbers.first) + ) + end - expect(Capybara.string(link)).not_to have_css('a[data-behavior="requests-modal"]') + it 'does not have requests-modal attribute for hoover items' do + expect(link).not_to have_css('a[data-behavior="requests-modal"]') + end + + it 'has a "_blank" target for hoover items' do + expect(link).to have_css('a[target="_blank"]') + end end end From cd3b9415e926eb1f9ad040d3a52f5161c36464e9 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Fri, 11 Aug 2017 13:55:58 -0700 Subject: [PATCH 6/8] Add bootstrap modal data attributes to request links for Hoover Library/Archives. --- app/helpers/request_link_helper.rb | 4 ++-- config/locales/searchworks.en.yml | 1 + spec/helpers/request_link_helper_spec.rb | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/request_link_helper.rb b/app/helpers/request_link_helper.rb index b46457b9a..7c4a67aed 100644 --- a/app/helpers/request_link_helper.rb +++ b/app/helpers/request_link_helper.rb @@ -37,9 +37,9 @@ def request_link_target(callnumber) end def link_data_attributes(callnumber) - return {} if Constants::HOOVER_LIBS.include?(callnumber.library) + return { behavior: 'requests-modal' } unless callnumber && Constants::HOOVER_LIBS.include?(callnumber.library) - { behavior: 'requests-modal' } + { toggle: 'tooltip', html: 'true', title: t('searchworks.request_link.aeon_note') } end def hoover_request_url(document, callnumber) diff --git a/config/locales/searchworks.en.yml b/config/locales/searchworks.en.yml index 0e3e211f1..99b93bf44 100644 --- a/config/locales/searchworks.en.yml +++ b/config/locales/searchworks.en.yml @@ -64,6 +64,7 @@ en: default: label: 'Field' request_link: + aeon_note: Requires Aeon signup/login
Opens in new tab default: Request HOOVER: Request on-site access HV-ARCHIVE: Request on-site access diff --git a/spec/helpers/request_link_helper_spec.rb b/spec/helpers/request_link_helper_spec.rb index 92f904b87..981d2c727 100644 --- a/spec/helpers/request_link_helper_spec.rb +++ b/spec/helpers/request_link_helper_spec.rb @@ -68,6 +68,11 @@ it 'has a "_blank" target for hoover items' do expect(link).to have_css('a[target="_blank"]') end + + it 'has the bootstrap tooltip data attributes' do + expect(link).to have_css('a[data-toggle="tooltip"]') + expect(link).to have_css('a[data-title^="Requires Aeon signup"]') + end end end From eea2dae7f7091dcd6913cf7ff0ddf9eb1ea5a979 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Mon, 9 Oct 2017 14:05:43 -0700 Subject: [PATCH 7/8] Add library instructions for Hoover and Hoover Archives. --- lib/constants.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/constants.rb b/lib/constants.rb index 7715a38f8..83e5cafe5 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -1218,6 +1218,14 @@ module Constants BROWSABLE_CALLNUMBERS = %w(LC DEWEY ALPHANUM) LIBRARY_INSTRUCTIONS = { + 'HOOVER' => { + heading: 'All items must be requested in advance', + text: 'Stanford ID holders may be able to check out some monographs marked "Available" next to the call number. "In-library use" call numbers are for reading-room use only.' + }, + 'HV-ARCHIVE' => { + heading: 'All items must be viewed on site', + text: "If there's a finding aid shown above, use the Online Archive of California link to request items. Otherwise, use the Request on-site access button below." + }, 'RUMSEYMAP' => { heading: 'All items must be viewed on site', text: 'Request items by Noon (12p) the day before your visit to allow for retrieval by staff. You can request at most 5 items per day.' From 112ec0ac1d4536454d0f0548ddef7534f6428ca0 Mon Sep 17 00:00:00 2001 From: Jessie Keck Date: Wed, 11 Oct 2017 14:47:44 -0700 Subject: [PATCH 8/8] Temporarily pull Hoover Archives from AEON links. --- lib/constants.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/constants.rb b/lib/constants.rb index 83e5cafe5..e421816f2 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -845,11 +845,11 @@ module Constants 'TECH-SERV', 'TEMP-LL'] - REQUEST_LIBS = ['HOOVER', 'HV-ARCHIVE', 'MEDIA-MTXT', 'RUMSEYMAP', 'SAL', 'SAL3', 'SAL-NEWARK', 'SPEC-COLL'].freeze + REQUEST_LIBS = ['HOOVER', 'MEDIA-MTXT', 'RUMSEYMAP', 'SAL', 'SAL3', 'SAL-NEWARK', 'SPEC-COLL'].freeze LOCATION_LEVEL_REQUEST_LOCS = ['SSRC-DATA'] - HOOVER_LIBS = %w[HOOVER HV-ARCHIVE].freeze + HOOVER_LIBS = %w[HOOVER].freeze REQUEST_LOCS = ['GUNST-30', 'FELTON-30', @@ -1222,10 +1222,6 @@ module Constants heading: 'All items must be requested in advance', text: 'Stanford ID holders may be able to check out some monographs marked "Available" next to the call number. "In-library use" call numbers are for reading-room use only.' }, - 'HV-ARCHIVE' => { - heading: 'All items must be viewed on site', - text: "If there's a finding aid shown above, use the Online Archive of California link to request items. Otherwise, use the Request on-site access button below." - }, 'RUMSEYMAP' => { heading: 'All items must be viewed on site', text: 'Request items by Noon (12p) the day before your visit to allow for retrieval by staff. You can request at most 5 items per day.'