Skip to content

Commit

Permalink
Show portfolio information
Browse files Browse the repository at this point in the history
Ryan Laddusaw committed Dec 11, 2024
1 parent 01096eb commit 31f1d30
Showing 2 changed files with 30 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/models/concerns/blacklight/document/email.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ module Email
def to_email_text
body = []
add_bibliographic_text(body)
add_online_text(body, self[:electronic_access_1display])
add_online_text(body, self[:electronic_access_1display], self[:electronic_portfolio_s])
body.join("\n") unless body.empty?
end

@@ -31,16 +31,23 @@ def add_bibliographic_text(body)
add_multi_valued_field(body, 'blacklight.email.text.format', self[:format])
end

def add_online_text(body, links_field)
def add_online_text(body, links_field, portfolio_fields)
body << I18n.t('blacklight.email.text.online') if links_field.present? || portfolio_fields.present?
if links_field.present?
body << I18n.t('blacklight.email.text.online')
links = JSON.parse(links_field)
links.each do |url, text|
link = "#{text[0]}: #{url}"
link = "#{text[1]} - " + link if text[1]
body << "\t" + link
end
end
if portfolio_fields.present?
portfolio_fields.each do |portfolio_field|
portfolio = JSON.parse(portfolio_field)
link = "#{portfolio['title']}: #{portfolio['url']}"
body << "\t" + link
end
end
end
end
end
20 changes: 20 additions & 0 deletions spec/views/orangelight/email_record.text.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -120,4 +120,24 @@
expect(rendered).not_to have_text('Message:')
end
end
describe 'with electronic portfolio' do
let(:properties) do
{
id: '9945502073506421',
title_display: 'The sociology of emotions / Jonathan H. Turner, Jan E. Stets.',
electronic_access_1display: '{"http://www.loc.gov/catdir/description/cam051/2004018645.html":["Publisher description"],"http://www.loc.gov/catdir/toc/ecip0421/2004018645.html":["Table of contents"]}',
author_display: ['Turner, Jonathan H.'],
format: ['Book'],
electronic_portfolio_s: [
'{"desc":null,"title":"Full Text","url":"https://na05.alma.exlibrisgroup.com/view/uresolver/01PRI_INST/openurl?u.ignore_date_coverage=true&portfolio_pid=53827030770006421&Force_direct=true","start":null,"end":"latest"}',
'{"desc":null,"title":"Second Title","url":"https://example.com","start":null,"end":"latest"}'
]
}
end

it 'includes the electronic portfolio link' do
expect(rendered).to have_text('Full Text')
expect(rendered).to have_text('Second Title')
end
end
end

0 comments on commit 31f1d30

Please sign in to comment.