diff --git a/app/assets/stylesheets/partials/_panels.scss b/app/assets/stylesheets/partials/_panels.scss index 12d527a2..de219fa9 100644 --- a/app/assets/stylesheets/partials/_panels.scss +++ b/app/assets/stylesheets/partials/_panels.scss @@ -98,34 +98,56 @@ } } -.filter-summary { +.search-summary { color: $black; background-color: $gray-l3; margin-top: 0; border: 0; - padding: 2rem; - padding-top: 1.5rem; + padding: 2rem 2rem 1rem 2rem; + .list-filter-summary, + .list-terms-summary { + @media (min-width: $bp-screen-md) { + display: flex; + } + } .list-filter-summary { - display: flex; - .hd-filter-summary { - margin-right: 2rem; - padding-top: 0.3rem; + padding-top: 1rem; + border-top: 1px solid $black; + } + .hd-search-summary { + margin-right: 2rem; + padding-top: 0.2rem; + white-space: nowrap; + } + .list-unbulleted { + margin-bottom: 0; + } + .applied-filter, + .applied-term { + font-size: $fs-small; + text-decoration: none; + margin-right: 2rem; + } + .applied-term { + margin-top: .5rem; + &:first-child { + margin-top: 0; + } + } + .keyword { + margin-bottom: 1.2rem; + } + .applied-filter { + padding: .5rem; + &::before { + font-family: FontAwesome; + content: '\f00d'; + padding-right: .25rem; } - .applied-filter { - 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; + &:hover, + &:focus { + color: $white; + background-color: $black; } } .clear-filters { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e11ebfb8..710d0aa5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,7 +15,7 @@ def index_page_title def results_page_title(query, character_limit = 50) return index_page_title unless query.present? - ignored_terms = %i[page advanced geobox geodistance] + ignored_terms = %i[page advanced geobox geodistance booleanType] terms = query.reject { |term| ignored_terms.include? term }.values.join(' ') terms = "#{terms.first(character_limit)}..." if terms.length > character_limit "#{terms} | #{page_title_base}" diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 223fd717..d7084468 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -44,8 +44,48 @@ def parse_geo_dates(dates) handle_unparsable_date(relevant_date) end + def applied_keyword(query) + relevant_terms = ['q'] + render_relevant_terms(query, relevant_terms) + end + + def applied_geobox_terms(query) + relevant_terms = %w[geoboxMinLatitude geoboxMaxLatitude geoboxMinLongitude geoboxMaxLongitude] + render_relevant_terms(query, relevant_terms) + end + + def applied_geodistance_terms(query) + relevant_terms = %w[geodistanceLatitude geodistanceLongitude geodistanceDistance] + render_relevant_terms(query, relevant_terms) + end + + def applied_advanced_terms(query) + relevant_terms = %w[title citation contributors fundingInformation identifiers locations subjects] + render_relevant_terms(query, relevant_terms) + end + private + # Query params need some treatment to look decent in the search summary panel. + def readable_param(param) + return 'Keyword anywhere' if param == 'q' + + if param.starts_with?('geodistance') + param = param.gsub('geodistance', '') + elsif param.starts_with?('geobox') + param = param.gsub(/geobox(Max|Min)/, '\1 ') + end + + param.titleize.humanize + end + + def render_relevant_terms(query, relevant_terms) + applied_terms = query.select { |param, _value| relevant_terms.include?(param.to_s) } + return unless applied_terms.present? + + applied_terms.filter_map { |param, value| "#{readable_param(param.to_s)}: #{value}" } + end + def handle_unparsable_date(date) if date.include? '-' extract_year(date, '-') diff --git a/app/views/search/_search_summary.html.erb b/app/views/search/_search_summary.html.erb index 1e8b8792..478f61ff 100644 --- a/app/views/search/_search_summary.html.erb +++ b/app/views/search/_search_summary.html.erb @@ -1,29 +1,71 @@ -<% return unless applied_filters(@enhanced_query).any? %> +<% 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?) %> -