Skip to content

Commit 3c5a268

Browse files
committed
Normalize fulfillment links
Why these changes are being introduced: Fulfillment link logic exists in three separate places. This is not necessary, as UXWS would like the link text to always be 'View full record.' Relevant ticket(s): - [USE-252](https://mitlibraries.atlassian.net/browse/USE-252) How this addresses that need: This simplifies fulfillment link logic and normalizes the text as requested. Side effects of this change: The nested conditional logic in the Primo result partial is starting to get some code smell. I find it unlikely that we'll want to render all of the links long-term, though, so I think we can accept this for now with the understanding that it can probably be simplified later.
1 parent d38b405 commit 3c5a268

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

app/helpers/search_helper.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ def link_to_tab(target, label = nil)
4141
end
4242
end
4343

44-
def view_online(result)
45-
return unless result[:source_link].present?
46-
47-
link_to 'View online', result[:source_link], class: 'button button-primary'
48-
end
49-
5044
def view_record(record_id)
5145
link_to 'View full record', record_path(id: record_id), class: 'button button-primary'
5246
end

app/views/search/_result.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</div>
5656

5757
<div class="result-get">
58-
<%= view_online(result) %>
58+
<%= view_record(result) %>
5959
</div>
6060
</div>
6161
</li>

app/views/search/_result_primo.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
<div class="result-get">
6161
<% if result[:links].present? %>
6262
<% result[:links].each do |link| %>
63-
<%= link_to link['kind'].titleize, link['url'], class: 'button' %>
63+
<% if link['kind'].downcase == 'full record' %>
64+
<%= view_record(link) %>
65+
<% else %>
66+
<%= link_to link['kind'].titleize, link['url'], class: 'button' %>
67+
<% end %>
6468
<% end %>
6569
<% end %>
6670
<% if Libkey.enabled? && result[:doi].present? %>

test/helpers/search_helper_test.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ class SearchHelperTest < ActionView::TestCase
2626
{ 'matchedField' => 'citation', 'matchedPhrases' => 'Datascientist, Jane' }], trim_highlights(result)
2727
end
2828

29-
test 'renders view_online link if source_link is present' do
30-
result = { title: 'A record', source_link: 'https://example.org' }
31-
assert_equal '<a class="button button-primary" href="https://example.org">View online</a>',
32-
view_online(result)
33-
end
34-
35-
test 'does not render view_online link if source_link is absent' do
36-
result = { title: 'A record' }
37-
assert_nil view_online(result)
38-
end
39-
4029
test 'parse_geo_dates returns issued over coverage' do
4130
dates = [{ 'kind' => 'Coverage', 'value' => '2009-01-01' },
4231
{ 'kind' => 'Issued', 'value' => '2011' }]

0 commit comments

Comments
 (0)