Search on the same URL by default
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
<h2><%= t("admin.debates.index.title") %></h2>
|
||||
|
||||
<% 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")) %>
|
||||
|
||||
<h3 class="inline-block"><%= page_entries_info @debates %></h3>
|
||||
|
||||
|
||||
@@ -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
|
||||
) %>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<h2><%= t("admin.organizations.search.title") %></h2>
|
||||
|
||||
<%= 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")) %>
|
||||
|
||||
<div id="search-results">
|
||||
<% if @organizations.any? %>
|
||||
|
||||
@@ -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? %>
|
||||
<div class="callout primary">
|
||||
|
||||
@@ -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")) %>
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
<h2><%= t("admin.proposals.index.title") %></h2>
|
||||
|
||||
<% 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")) %>
|
||||
|
||||
<h3><%= page_entries_info @proposals %></h3>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<h2><%= t("admin.users.index.title") %></h2>
|
||||
|
||||
<%= render Admin::SearchComponent.new(
|
||||
url: admin_users_path,
|
||||
label: t("admin.users.search.placeholder"),
|
||||
remote: true
|
||||
) %>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<main>
|
||||
<h2><%= t("management.proposals.index.title") %></h2>
|
||||
|
||||
<%= 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")) %>
|
||||
|
||||
<div class="management-list">
|
||||
<div class="proposals-list">
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<h2><%= t("moderation.users.index.title") %></h2>
|
||||
|
||||
<%= 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? %>
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
Reference in New Issue
Block a user