Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def results
if Flipflop.enabled?(:gdt)
# Keep existing GDT behavior unchanged
load_gdt_results
render 'results_geo'
else
case @active_tab
when 'primo'
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_result_primo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h3 class="record-title">
<span class="sr">Title: </span>
<% if result_primo['links']&.find { |link| link['kind'] == 'full record' } %>
<%= link_to(result_primo['title'], result_primo['links'].find { |link| link['kind'] == 'full record' }['url'], target: '_blank', rel: 'noopener') %>
<%= link_to(result_primo['title'], result_primo['links'].find { |link| link['kind'] == 'full record' }['url']) %>
<% else %>
<%= result_primo['title'] %>
<% end %>
Expand Down
70 changes: 3 additions & 67 deletions app/views/search/_search_summary.html.erb
Original file line number Diff line number Diff line change
@@ -1,71 +1,7 @@
<% return unless (applied_filters(@enhanced_query).present? ||
applied_keyword(@enhanced_query).present? ||
applied_geobox_terms(@enhanced_query).present? ||
applied_geodistance_terms(@enhanced_query).present? ||
applied_advanced_terms(@enhanced_query).present?) %>
<% return unless params[:q].present? %>

<aside class="search-summary">
<div class="list-terms-summary">
<h2 class="hd-search-summary hd-5">Applied search terms: </h2>
<ul class="list-unbulleted">
<% if applied_keyword(@enhanced_query).present? %>
<li class="applied-term keyword"><%= applied_keyword(@enhanced_query).first %></li>
<% end %>
<% if applied_geobox_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_geobox_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
<% if applied_geodistance_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_geodistance_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
<% if applied_advanced_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_advanced_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
</ul>
<h2 class="hd-search-summary hd-5">You searched for: <%= params[:q] %></h2>
</div>

<% if applied_filters(@enhanced_query).any? %>
<div class="list-filter-summary">
<h2 class="hd-search-summary hd-5">Applied filters: </h2>
<ul class="list-inline">
<% applied_filters(@enhanced_query).each do |filter| %>
<li>
<a class="applied-filter"
href="<%= results_path(remove_filter(@enhanced_query, filter.keys[0], filter.values[0])) %>">
<%= "#{nice_labels[filter.keys[0]] || filter.keys[0]}:" %>
<% if Flipflop.enabled?(:gdt) %>
<%= "#{gdt_sources(filter.values[0], filter.keys[0])}" %>
<% else %>
<%= "#{filter.values[0]}" %>
<% end %>
<span class="sr">Remove applied filter?</span>
</a>
</li>
<% end %>
</ul>
</div>
<% if applied_filters(@enhanced_query).length > 1 %>
<div class="clear-filters">
<a class="btn button-primary"
href="<%= results_path(remove_all_filters(@enhanced_query)) %>">Clear all filters</a>
</div>
<% end %>
<% end %>
</aside>
</aside>
71 changes: 71 additions & 0 deletions app/views/search/_search_summary_geo.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<% return unless (applied_filters(@enhanced_query).present? ||
applied_keyword(@enhanced_query).present? ||
applied_geobox_terms(@enhanced_query).present? ||
applied_geodistance_terms(@enhanced_query).present? ||
applied_advanced_terms(@enhanced_query).present?) %>

<aside class="search-summary">
<div class="list-terms-summary">
<h2 class="hd-search-summary hd-5">Applied search terms: </h2>
<ul class="list-unbulleted">
<% if applied_keyword(@enhanced_query).present? %>
<li class="applied-term keyword"><%= applied_keyword(@enhanced_query).first %></li>
<% end %>
<% if applied_geobox_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_geobox_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
<% if applied_geodistance_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_geodistance_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
<% if applied_advanced_terms(@enhanced_query).present? %>
<li>
<ul class="list-inline terms-list">
<% applied_advanced_terms(@enhanced_query).each do |term| %>
<li class="applied-term"><%= term %></li>
<% end %>
</ul>
</li>
<% end %>
</ul>
</div>

<% if applied_filters(@enhanced_query).any? %>
<div class="list-filter-summary">
<h2 class="hd-search-summary hd-5">Applied filters: </h2>
<ul class="list-inline">
<% applied_filters(@enhanced_query).each do |filter| %>
<li>
<a class="applied-filter"
href="<%= results_path(remove_filter(@enhanced_query, filter.keys[0], filter.values[0])) %>">
<%= "#{nice_labels[filter.keys[0]] || filter.keys[0]}:" %>
<% if Flipflop.enabled?(:gdt) %>
<%= "#{gdt_sources(filter.values[0], filter.keys[0])}" %>
<% else %>
<%= "#{filter.values[0]}" %>
<% end %>
<span class="sr">Remove applied filter?</span>
</a>
</li>
<% end %>
</ul>
</div>
<% if applied_filters(@enhanced_query).length > 1 %>
<div class="clear-filters">
<a class="btn button-primary"
href="<%= results_path(remove_all_filters(@enhanced_query)) %>">Clear all filters</a>
</div>
<% end %>
<% end %>
</aside>
7 changes: 0 additions & 7 deletions app/views/search/_search_summary_use.html.erb

This file was deleted.

54 changes: 14 additions & 40 deletions app/views/search/results.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
<%= render partial: "shared/site_title" %>

<%= render partial: "form" %>
<% if Flipflop.enabled?(:gdt) %>
<%= render partial: "search_summary" %>
<% else %>
<%= render partial: "search_summary_use" %>
<% end %>
<%= render partial: "search_summary" %>

<% if ENV.fetch('FACT_PANELS_ENABLED', false).present? %>
<div id="hint" aria-live="polite">
Expand All @@ -26,46 +22,23 @@

<%= render(partial: 'shared/error', collection: @errors) %>

<% unless Flipflop.enabled?(:gdt) %>
<!-- Tab Navigation -->
<div class="tab-navigation top-space">
<%= link_to "Primo", results_path(params.permit(:q, :per_page, :page).merge(tab: 'primo')),
class: "tab-link #{'active' if @active_tab == 'primo'}",
data: { turbo_frame: "search-results" } %>
<%= link_to "TIMDEX", results_path(params.permit(:q, :per_page, :page).merge(tab: 'timdex')),
class: "tab-link #{'active' if @active_tab == 'timdex'}",
data: { turbo_frame: "search-results" } %>
</div>
<% end %>
<!-- Tab Navigation -->
<div class="tab-navigation top-space">
<%= link_to "Primo", results_path(params.permit(:q, :per_page, :page).merge(tab: 'primo')),
class: "tab-link #{'active' if @active_tab == 'primo'}",
data: { turbo_frame: "search-results" } %>
<%= link_to "TIMDEX", results_path(params.permit(:q, :per_page, :page).merge(tab: 'timdex')),
class: "tab-link #{'active' if @active_tab == 'timdex'}",
data: { turbo_frame: "search-results" } %>
</div>

<%= turbo_frame_tag "search-results" do %>
<div class="<%= @filters.present? ? 'layout-1q3q' : 'layout-3q1q' %> layout-band top-space">
<% if @filters.present? %>
<aside id="filters" class="col1q">
<button id="filter-toggle"><span class="filter-toggle-name">Filter your results</span><span class="filter-toggle-hide">Hide filters</span></button>
<div id="filter-container" class="hidden-md">
<div class="hidden-md">
<h2 class="hd-3">Filter your results</h2>
</div>
<% @filters&.each_with_index do |(category, values), index| %>
<% if index == 0 %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: true }) %>
<% else %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: false }) %>
<% end %>
<% end %>
</div>
<%= render partial: 'shared/ask', locals: { display: 'view-lg' } %>
</aside>
<% end %>

<div class="layout-3q1q layout-band top-space">
<main id="results" class="col3q wrap-results">
<% if @results.present? && @errors.blank? %>
<h2 class="hd-3 results-context"><%= results_summary(@pagination[:hits]) %> returned</h2>
<ol class="results-list" start="<%= @pagination[:start] %>">
<% if Flipflop.enabled?(:gdt) %>
<%= render(partial: 'search/result_geo', collection: @results) %>
<% elsif @active_tab == 'primo' %>
<% if @active_tab == 'primo' %>
<%= render(partial: 'search/result_primo', collection: @results) %>
<% else %>
<%= render(partial: 'search/result', collection: @results) %>
Expand All @@ -79,7 +52,8 @@
</main>
</div>
<% end %>
<%= render partial: 'shared/ask', locals: { display: 'aside' } if @results.blank? %>

<%= render partial: 'shared/ask', locals: { display: 'aside' } if @results.blank? %>

<% if @results.present? %>
<div id="pagination">
Expand Down
71 changes: 71 additions & 0 deletions app/views/search/results_geo.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<%= content_for(:title, results_page_title(@enhanced_query)) %>

<% content_for :additional_meta_tag do %>
<meta name="robots" content="noindex, nofollow" />
<% end %>

<div class="space-wrap">

<%= render partial: "shared/site_title" %>

<%= render partial: "form" %>
<%= render partial: "search_summary_geo" %>

<% if ENV.fetch('FACT_PANELS_ENABLED', false).present? %>
<div id="hint" aria-live="polite">
<%= render(partial: 'search/issn') if fact_enabled?('issn') %>
<%= render(partial: 'search/isbn') if fact_enabled?('isbn') %>
<%= render(partial: 'search/pmid') if fact_enabled?('pmid') %>
<%= render(partial: 'search/doi') if fact_enabled?('doi') %>
</div>
<% end %>

<%= render(partial: 'shared/error', collection: @errors) %>

<div class="<%= @filters.present? ? 'layout-1q3q' : 'layout-3q1q' %> layout-band top-space">
<% if @filters.present? %>
<aside id="filters" class="col1q">
<button id="filter-toggle"><span class="filter-toggle-name">Filter your results</span><span class="filter-toggle-hide">Hide filters</span></button>
<div id="filter-container" class="hidden-md">
<div class="hidden-md">
<h2 class="hd-3">Filter your results</h2>
</div>
<% @filters&.each_with_index do |(category, values), index| %>
<% if index == 0 %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: true }) %>
<% else %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: false }) %>
<% end %>
<% end %>
</div>
<%= render partial: 'shared/ask', locals: { display: 'view-lg' } %>
</aside>
<% end %>

<main id="results" class="col3q wrap-results">
<% if @results.present? && @errors.blank? %>
<h2 class="hd-3 results-context"><%= results_summary(@pagination[:hits]) %> returned</h2>
<ol class="results-list" start="<%= @pagination[:start] %>">
<%= render(partial: 'search/result_geo', collection: @results) %>
</ol>
<% elsif @errors.blank? %>
<div class="no-results">
<p class="hd-2">No results found for your search</p>
</div>
<% end %>
</main>
</div>

<%= render partial: 'shared/ask', locals: { display: 'aside' } if @results.blank? %>

<% if @results.present? %>
<div id="pagination">
<%= render partial: "pagination" %>
</div>
<%= render partial: 'shared/ask', locals: { display: 'view-md' } %>
<% end %>
</div>

<%= render(partial: 'trigger_tacos') if tacos_enabled? %>

<%= javascript_include_tag "filters" %>