Skip to content

Commit fb2a6c5

Browse files
authored
Merge pull request #313 from MITLibraries/use-251-no-eyebrows-for-some-tabs
Only show the eyebrow in multi-source tabs
2 parents 6f12d6a + 4b07c15 commit fb2a6c5

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

app/helpers/record_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ def location(loc)
186186
"<strong>#{loc[:name]}</strong> #{loc[:collection]} (#{loc[:call_number]})"
187187
end
188188

189+
# Returns true if the active tab includes multiple sources.
190+
# As our tabs adjust over time, we will need to revisit this logic.
191+
def multi_source_tab?
192+
%w[all primo timdex website].include?(@active_tab)
193+
end
194+
189195
private
190196

191197
def render_kind_value(list)

app/views/search/_result.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<li class="result use">
22
<div class="result-content">
3-
<p class="eyebrow"><%= result[:eyebrow] %></p>
3+
<% if multi_source_tab? && result[:eyebrow].present? %>
4+
<p class="eyebrow"><%= result[:eyebrow] %></p>
5+
<% end %>
46
<h3 class="record-title">
57
<span class="sr">Title: </span>
68
<%= link_to_result(result) %>

app/views/search/_result_primo.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<li class="result primo">
22
<div class="result-content">
3-
<p class="eyebrow"><%= result[:eyebrow] %></p>
3+
<% if multi_source_tab? && result[:eyebrow].present? %>
4+
<p class="eyebrow"><%= result[:eyebrow] %></p>
5+
<% end %>
46
<h3 class="record-title">
57
<span class="sr">Title: </span>
68
<% if result[:links]&.find { |link| link['kind'] == 'full record' } %>

test/helpers/record_helper_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,18 @@ class RecordHelperTest < ActionView::TestCase
387387
expected = "<i class='fa-sharp fa-solid fa-question' aria-hidden='true''></i>"
388388
assert_equal expected, icon('question')
389389
end
390+
391+
test 'multi_source_tab? returns true for tabs that combine sources' do
392+
%w[all primo timdex website].each do |tab|
393+
@active_tab = tab
394+
assert multi_source_tab?
395+
end
396+
end
397+
398+
test 'multi_source_tab? returns false for other tabs' do
399+
%w[alma cdi aspace timdex_alma fake_tab].each do |tab|
400+
@active_tab = tab
401+
assert_not multi_source_tab?
402+
end
403+
end
390404
end

0 commit comments

Comments
 (0)