diff --git a/app/components/admin/search_component.rb b/app/components/admin/search_component.rb index da18311ec..e7c4a3e45 100644 --- a/app/components/admin/search_component.rb +++ b/app/components/admin/search_component.rb @@ -1,12 +1,16 @@ class Admin::SearchComponent < ApplicationComponent - attr_reader :url, :label, :form_options + attr_reader :label, :form_options - def initialize(url:, label:, **form_options) - @url = url + 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 diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb index bac99fdde..7a743aea1 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/debates/index.html.erb @@ -5,10 +5,7 @@

<%= t("admin.debates.index.title") %>

<% if @debates.any? %> - <%= render Admin::SearchComponent.new( - url: admin_debates_path, - label: t("admin.shared.debate_search.placeholder") - ) %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.debate_search.placeholder")) %>

<%= page_entries_info @debates %>

diff --git a/app/views/admin/local_census_records/index.html.erb b/app/views/admin/local_census_records/index.html.erb index 3ac46dce2..5de47ed85 100644 --- a/app/views/admin/local_census_records/index.html.erb +++ b/app/views/admin/local_census_records/index.html.erb @@ -9,7 +9,6 @@ class: "button float-right hollow" %> <%= render Admin::SearchComponent.new( - url: admin_local_census_records_path, label: t("admin.local_census_records.index.search.placeholder"), remote: true ) %> diff --git a/app/views/admin/organizations/search.html.erb b/app/views/admin/organizations/search.html.erb index 2c40759f1..40a08a7c9 100644 --- a/app/views/admin/organizations/search.html.erb +++ b/app/views/admin/organizations/search.html.erb @@ -1,9 +1,6 @@

<%= t("admin.organizations.search.title") %>

-<%= render Admin::SearchComponent.new( - url: search_admin_organizations_path, - label: t("admin.organizations.index.search_placeholder") -) %> +<%= render Admin::SearchComponent.new(label: t("admin.organizations.index.search_placeholder")) %>
<% if @organizations.any? %> diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index fd1353a72..4954801a2 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -4,10 +4,7 @@ <%= link_to t("admin.booths.index.add_booth"), new_admin_booth_path, class: "button float-right" %> <% end %> -<%= render Admin::SearchComponent.new( - url: admin_booths_path, - label: t("admin.shared.booths_search.placeholder") -) %> +<%= render Admin::SearchComponent.new(label: t("admin.shared.booths_search.placeholder")) %> <% if @booths.empty? %>
diff --git a/app/views/admin/poll/questions/_search.html.erb b/app/views/admin/poll/questions/_search.html.erb index 5f627756b..73730dcd6 100644 --- a/app/views/admin/poll/questions/_search.html.erb +++ b/app/views/admin/poll/questions/_search.html.erb @@ -1,4 +1 @@ -<%= render Admin::SearchComponent.new( - url: admin_questions_path, - label: t("admin.shared.poll_questions_search.placeholder") -) %> +<%= render Admin::SearchComponent.new(label: t("admin.shared.poll_questions_search.placeholder")) %> diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb index 43693ea1e..075e70278 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -5,10 +5,7 @@

<%= t("admin.proposals.index.title") %>

<% if @proposals.any? %> - <%= render Admin::SearchComponent.new( - url: admin_proposals_path, - label: t("admin.shared.proposal_search.placeholder") - ) %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.proposal_search.placeholder")) %>

<%= page_entries_info @proposals %>

diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 49165c31e..96ece4ae5 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,7 +1,6 @@

<%= t("admin.users.index.title") %>

<%= render Admin::SearchComponent.new( - url: admin_users_path, label: t("admin.users.search.placeholder"), remote: true ) %> diff --git a/app/views/management/proposals/index.html.erb b/app/views/management/proposals/index.html.erb index 21397b553..a5862961e 100644 --- a/app/views/management/proposals/index.html.erb +++ b/app/views/management/proposals/index.html.erb @@ -1,10 +1,7 @@

<%= t("management.proposals.index.title") %>

- <%= render Admin::SearchComponent.new( - url: management_proposals_path, - label: t("admin.shared.proposal_search.placeholder") - ) %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.proposal_search.placeholder")) %>
diff --git a/app/views/moderation/users/index.html.erb b/app/views/moderation/users/index.html.erb index 6ae397dd4..9008f8fec 100644 --- a/app/views/moderation/users/index.html.erb +++ b/app/views/moderation/users/index.html.erb @@ -1,9 +1,6 @@

<%= t("moderation.users.index.title") %>

-<%= render Admin::SearchComponent.new( - url: moderation_users_path, - label: t("moderation.users.index.search_placeholder") -) %> +<%= render Admin::SearchComponent.new(label: t("moderation.users.index.search_placeholder")) %> <% if @users.present? %>

<%= page_entries_info @users %>