diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 57f83f475..047ba1059 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -32,26 +32,11 @@ def search_and_filter(user, search_params = '', selected_facets = {}, page: 1, s any do # Set all facets normal_facets.each do |facet_title, facet_value| - # Start date is a AND search parameter in my opinion. - if facet_title == 'start' + any do # Conjunction clause + # Add to array that get executed lower down active_facets[facet_title] ||= [] - lb, ub = Facets.process(facet_title, facet_value) - # We should think about timezone handling here - if lb && ub - active_facets[facet_title] << with(facet_title).between(lb..ub) - elsif lb - active_facets[facet_title] << with(facet_title).greater_than_or_equal_to(lb) - elsif ub - active_facets[facet_title] << with(facet_title).less_than_or_equal_to(ub) - else - end - else - any do # Conjunction clause - # Add to array that get executed lower down - active_facets[facet_title] ||= [] - val = Facets.process(facet_title, facet_value) - active_facets[facet_title] << with(facet_title, val) - end + val = Facets.process(facet_title, facet_value) + active_facets[facet_title] << with(facet_title, val) end end end diff --git a/app/views/search/common/_facet_sidebar.html.erb b/app/views/search/common/_facet_sidebar.html.erb index 83be37983..0ff3a4678 100644 --- a/app/views/search/common/_facet_sidebar.html.erb +++ b/app/views/search/common/_facet_sidebar.html.erb @@ -36,12 +36,13 @@ Variable that should be available <% boolean_facets, regular_facets = available_facets(resources).partition { |f| f.field_name == :online } %> - <% regular_facets.each do |facet| %> - <% if facet.field_name == :start %> - <%= render partial: 'search/common/facet_sidebar_date_filter', locals: { facet: facet, resources: resources } %> - <% else %> - <%= render partial: 'search/common/facet_sidebar_filter', locals: { facet: facet, resources: resources } %> - <% end %> + <% if resource_type.name == 'Event' %> + <%= render partial: 'search/common/facet_sidebar_date_filter', locals: { facet_field: 'start' } %> + <% end %> + + <%# We ignore the start facet, since this needs to be always available, not just when there are records%> + <% regular_facets.reject{ |f| f.field_name.to_s == 'start' }.each do |facet| %> + <%= render partial: 'search/common/facet_sidebar_filter', locals: { facet: facet, resources: resources } %> <% end %> <% boolean_facets.each do |facet| %> diff --git a/app/views/search/common/_facet_sidebar_date_filter.html.erb b/app/views/search/common/_facet_sidebar_date_filter.html.erb index bcaab96ab..8ca5adcb0 100644 --- a/app/views/search/common/_facet_sidebar_date_filter.html.erb +++ b/app/views/search/common/_facet_sidebar_date_filter.html.erb @@ -1,4 +1,3 @@ -<% facet_field = facet.field_name.to_s %> <% lb, ub = params[facet_field]&.split('/') %>