Skip to content

Commit

Permalink
Add search summary panel
Browse files Browse the repository at this point in the history
Why these changes are being introduced:

It would be helpful if users could see what filters they've
applied to a search directly below the search bar, which would
also provide another path to remove filters.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/GDT-142

How this addresses that need:

This provides the requested panel. We had been calling this a
"filter removal" panel, but I ended up naming it "search summary"
to avoid any confusion with the filter sidebar.

Side effects of this change:

The "You searched for" list has been removed, as this feature
replaces it.
  • Loading branch information
jazairi committed Feb 14, 2024
1 parent fe1fa4b commit 37b1431
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 39 deletions.
33 changes: 33 additions & 0 deletions app/assets/stylesheets/partials/_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,36 @@
}
}
}

.search-summary {
color: $black;
background-color: $gray-l3;
margin-top: 0;
border: 0;
padding: 2rem;
padding-top: 1.5rem;
display: flex;
.hd-search-summary {
margin-right: 2rem;
padding-top: 0.3rem;
}
a {
font-size: $fs-small;
text-decoration: none;
padding: .5rem;
&::before {
font-family: FontAwesome;
content: '\f00d';
padding-right: .25rem;
}
&:hover,
&:focus {
color: $white;
background-color: $black;
}
margin-right: 2rem;
}
@media (max-width: $bp-screen-md) {
display: block;
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/partials/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* basic search bar */
.basic-search {
background-color: #989898;
margin-bottom: 1rem;
margin-bottom: 0rem;
padding: 1.6rem 2rem;

details {
Expand Down
19 changes: 19 additions & 0 deletions app/views/search/_search_summary.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% return if @filters.empty? %>

<div class="search-summary">
<h2 class="hd-search-summary hd-5">You searched for: </h2>
<ul class="list-search-summary list-inline">
<% @filters.each do |category, values| %>
<% values.each do |term| %>
<li>
<% if filter_applied?(@enhanced_query[category.to_sym], term['key']) %>
<a href="<%= results_path(remove_filter(@enhanced_query, category.to_sym, term['key'])) %>">
<%= "#{category}: #{term['key']}" %>
<span class="sr">Remove applied filter?</span>
</a>
<% end %>
</li>
<% end %>
<% end %>
</ul>
</div>
41 changes: 3 additions & 38 deletions app/views/search/results.html.erb
Original file line number Diff line number Diff line change
@@ -1,43 +1,8 @@
<%= content_for(:title, "Search Results | MIT Libraries") %>

<div class="space-wrap">

<p>Showing results for:
<ul>
<% if @enhanced_query[:q].present? %>
<li>Keyword anywhere: <%= @enhanced_query[:q] %></li>
<% end %>
<% if @enhanced_query[:citation].present? %>
<li>Citation: <%= @enhanced_query[:citation] %></li>
<% end %>
<% if @enhanced_query[:contentType].present? %>
<li>Content type: <%= @enhanced_query[:contentType] %></li>
<% end %>
<% if @enhanced_query[:contributors].present? %>
<li>Contributors: <%= @enhanced_query[:contributors] %></li>
<% end %>
<% if @enhanced_query[:fundingInformation].present? %>
<li>Funders: <%= @enhanced_query[:fundingInformation] %></li>
<% end %>
<% if @enhanced_query[:identifiers].present? %>
<li>Identifiers: <%= @enhanced_query[:identifiers] %></li>
<% end %>
<% if @enhanced_query[:locations].present? %>
<li>Locations: <%= @enhanced_query[:locations] %></li>
<% end %>
<% if @enhanced_query[:subjects].present? %>
<li>Subjects: <%= @enhanced_query[:subjects] %></li>
<% end %>
<% if @enhanced_query[:title].present? %>
<li>Title: <%= @enhanced_query[:title] %></li>
<% end %>
<% if @enhanced_query[:source].present? %>
<li>Source: <%= @enhanced_query[:source] %></li>
<% end %>
</ul>
</p>

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

<div id="hint" aria-live="polite">
<%= render(partial: 'search/issn') %>
Expand All @@ -56,9 +21,9 @@
<h3 class="hd-4"><em><%= results_summary(@pagination[:hits]) %></em></h3>
<% @filters&.each_with_index do |(category, values), index| %>
<% if index == 0 %>
<%= render(partial: 'search/filter', locals: {category: category, values: values, first: true }) %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: true }) %>
<% else %>
<%= render(partial: 'search/filter', locals: {category: category, values: values, first: false }) %>
<%= render(partial: 'search/filter', locals: { category: category, values: values, first: false }) %>
<% end %>
<% end %>
</div>
Expand Down

0 comments on commit 37b1431

Please sign in to comment.