2020-03-09 12:13:27 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-06-22 20:38:13 +02:00
|
|
|
module SearchHelper
|
|
|
|
def facet_list(facets)
|
|
|
|
return unless facets.present?
|
2020-03-09 12:13:27 +01:00
|
|
|
|
2015-06-22 20:38:13 +02:00
|
|
|
content_tag(:ul) do
|
2015-06-22 20:58:25 +02:00
|
|
|
facets.each do |facet|
|
2015-06-22 20:38:13 +02:00
|
|
|
concat content_tag(:li,
|
2015-06-22 21:11:51 +02:00
|
|
|
"#{facet.term} (#{facet.count})",
|
2020-03-09 12:13:27 +01:00
|
|
|
class: 'facet')
|
2015-06-22 20:38:13 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-22 21:33:40 +02:00
|
|
|
|
2015-10-10 07:45:30 +02:00
|
|
|
def filter_select(builder, name, desc, facets, selected)
|
2015-06-22 21:33:40 +02:00
|
|
|
capture do
|
2020-03-09 12:13:27 +01:00
|
|
|
concat(builder.label(name, desc))
|
2015-06-22 21:33:40 +02:00
|
|
|
concat(
|
2020-03-09 12:13:27 +01:00
|
|
|
builder.select(name,
|
|
|
|
options_from_collection_for_select(facets, :term, :term_with_count, selected),
|
|
|
|
{ include_blank: true },
|
|
|
|
{ onchange: 'this.form.submit();' })
|
2015-06-22 21:33:40 +02:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2015-06-22 20:38:13 +02:00
|
|
|
end
|