Files
grecia/app/components/admin/search_component.rb
Javi Martín 92941d3304 Keep filters in admin search
While this bug was already present in the general admin search, the
combination of both search and filters was very uncommon. I've only
found this combinations in the users section, where you've got the
"erased" filter, but in this case searching for erased users doesn't
really make sense since their username and email have been deleted and
so there's nothing to find.

So the hidden content seemed to be the only affected section. However,
we're adding the field to every section so we don't have to make sure we
add it when we need it (like we did in the SDGManagement section).
2022-08-23 14:33:55 +02:00

34 lines
634 B
Ruby

class Admin::SearchComponent < ApplicationComponent
attr_reader :label, :form_options
def initialize(label:, url: nil, **form_options)
@label = label
@url = url
@form_options = form_options
end
def url
@url || request.path
end
private
def search_terms
params[:search]
end
def options
{ method: :get, role: "search" }.merge(form_options)
end
def hidden_current_filter_tag
hidden_field_tag(:filter, current_filter) if current_filter
end
def current_filter
if helpers.respond_to?(:current_filter)
helpers.current_filter
end
end
end