diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 0000000..d1c5945 --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,13 @@ +module SearchHelper + def facet_list(facets) + return unless facets.present? + content_tag(:ul) do + facets.each do |term, count| + concat content_tag(:li, + "#{term} (#{count})", + class: "facet" + ) + end + end + end +end diff --git a/app/views/search/index.html.slim b/app/views/search/index.html.slim index 91f2428..5a1dc06 100644 --- a/app/views/search/index.html.slim +++ b/app/views/search/index.html.slim @@ -1,17 +1,13 @@ div = render 'search/form' -.row - .small-4.columns - ul - - @paper_type_facets.each do |paper_type, count| - li.facet - = "#{paper_type} (#{count})" - .small-4.columns.end - ul - - @originator_facets.each do |originator, count| - li.facet - = "#{originator} (#{count})" + +- if params[:q].present? + .row + .small-4.columns + = facet_list(@paper_type_facets) + .small-4.columns.end + = facet_list(@originator_facets) .clearfix - if params[:q].present?