Reuse admin search component in other sections
There are some sections where we are not reusing it: * The budget investments search is completely different, so this component isn't appropriate there * Booth assignment and officers are slightly different, and I'm not entirely sure it's safe to refactor these cases
This commit is contained in:
@@ -7,8 +7,6 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@polls = Poll.not_budget
|
@polls = Poll.not_budget
|
||||||
@search = search_params[:search]
|
|
||||||
|
|
||||||
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")
|
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")
|
||||||
|
|
||||||
@proposals = Proposal.successful.sort_by_confidence_score
|
@proposals = Proposal.successful.sort_by_confidence_score
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
<h2><%= t("admin.debates.index.title") %></h2>
|
<h2><%= t("admin.debates.index.title") %></h2>
|
||||||
|
|
||||||
<% if @debates.any? %>
|
<% if @debates.any? %>
|
||||||
<%= render "/admin/shared/debate_search", url: admin_debates_path %>
|
<%= render Admin::SearchComponent.new(
|
||||||
|
url: admin_debates_path,
|
||||||
|
label: t("admin.shared.debate_search.placeholder")
|
||||||
|
) %>
|
||||||
|
|
||||||
<h3 class="inline-block"><%= page_entries_info @debates %></h3>
|
<h3 class="inline-block"><%= page_entries_info @debates %></h3>
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,11 @@
|
|||||||
new_admin_local_census_records_import_path,
|
new_admin_local_census_records_import_path,
|
||||||
class: "button float-right hollow" %>
|
class: "button float-right hollow" %>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render Admin::SearchComponent.new(
|
||||||
<%= form_tag admin_local_census_records_path, method: :get, remote: true do %>
|
url: admin_local_census_records_path,
|
||||||
<div class="input-group">
|
label: t("admin.local_census_records.index.search.placeholder"),
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.local_census_records.index.search.placeholder") %>
|
remote: true
|
||||||
<div class="input-group-button">
|
) %>
|
||||||
<%= submit_tag t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="local_census_records">
|
<div id="local_census_records">
|
||||||
<%= render "local_census_records" %>
|
<%= render "local_census_records" %>
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
<h2><%= t("admin.organizations.index.title") %></h2>
|
<h2><%= t("admin.organizations.index.title") %></h2>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render Admin::SearchComponent.new(
|
||||||
<%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %>
|
url: search_admin_organizations_path,
|
||||||
<div class="input-group">
|
label: t("admin.organizations.index.search_placeholder")
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.organizations.index.search_placeholder") %>
|
) %>
|
||||||
|
|
||||||
<div class="input-group-button">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<%= render "shared/filter_subnav", i18n_namespace: "admin.organizations.index" %>
|
<%= render "shared/filter_subnav", i18n_namespace: "admin.organizations.index" %>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
<h2><%= t("admin.organizations.search.title") %></h2>
|
<h2><%= t("admin.organizations.search.title") %></h2>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render Admin::SearchComponent.new(
|
||||||
<%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %>
|
url: search_admin_organizations_path,
|
||||||
<div class="input-group">
|
label: t("admin.organizations.index.search_placeholder")
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.organizations.index.search_placeholder") %>
|
) %>
|
||||||
<div class="input-group-button">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="search-results">
|
<div id="search-results">
|
||||||
<% if @organizations.any? %>
|
<% if @organizations.any? %>
|
||||||
|
|||||||
@@ -4,7 +4,10 @@
|
|||||||
<%= link_to t("admin.booths.index.add_booth"), new_admin_booth_path, class: "button float-right" %>
|
<%= link_to t("admin.booths.index.add_booth"), new_admin_booth_path, class: "button float-right" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "/admin/shared/booth_search", url: admin_booths_path %>
|
<%= render Admin::SearchComponent.new(
|
||||||
|
url: admin_booths_path,
|
||||||
|
label: t("admin.shared.booths_search.placeholder")
|
||||||
|
) %>
|
||||||
|
|
||||||
<% if @booths.empty? %>
|
<% if @booths.empty? %>
|
||||||
<div class="callout primary">
|
<div class="callout primary">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<p><%= t("admin.poll_officers.search.help") %></p>
|
<p><%= t("admin.poll_officers.search.help") %></p>
|
||||||
|
|
||||||
<%= form_tag search_admin_officers_path, method: :get, remote: true do %>
|
<%= render Admin::SearchComponent.new(
|
||||||
<div class="input-group">
|
url: search_admin_officers_path,
|
||||||
<%= text_field_tag :search, "",
|
label: t("admin.poll_officers.search.email_placeholder"),
|
||||||
placeholder: t("admin.poll_officers.search.email_placeholder") %>
|
remote: true
|
||||||
<div class="input-group-button">
|
) %>
|
||||||
<%= submit_tag t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<h2><%= t("admin.poll_officers.index.title") %></h2>
|
<h2><%= t("admin.poll_officers.index.title") %></h2>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render "search" %>
|
||||||
<%= render "search" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="search-result"></div>
|
<div id="search-result"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<%= form_tag(admin_questions_path, method: :get) do |f| %>
|
<%= render Admin::SearchComponent.new(
|
||||||
<div class="input-group">
|
url: admin_questions_path,
|
||||||
<%= text_field_tag :search,
|
label: t("admin.shared.poll_questions_search.placeholder")
|
||||||
@search,
|
) %>
|
||||||
placeholder: t("admin.shared.poll_questions_search.placeholder") %>
|
|
||||||
<div class="input-group-button">
|
|
||||||
<%= submit_tag t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
<%= link_to t("admin.questions.index.create"), new_admin_question_path,
|
<%= link_to t("admin.questions.index.create"), new_admin_question_path,
|
||||||
class: "button float-right" %>
|
class: "button float-right" %>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render "search" %>
|
||||||
<%= render "search" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tabs-content" data-tabs-content="questions-tabs">
|
<div class="tabs-content" data-tabs-content="questions-tabs">
|
||||||
<%= render "filter_subnav" %>
|
<%= render "filter_subnav" %>
|
||||||
|
|||||||
@@ -5,7 +5,10 @@
|
|||||||
<h2><%= t("admin.proposals.index.title") %></h2>
|
<h2><%= t("admin.proposals.index.title") %></h2>
|
||||||
|
|
||||||
<% if @proposals.any? %>
|
<% if @proposals.any? %>
|
||||||
<%= render "/admin/shared/proposal_search", url: admin_proposals_path %>
|
<%= render Admin::SearchComponent.new(
|
||||||
|
url: admin_proposals_path,
|
||||||
|
label: t("admin.shared.proposal_search.placeholder")
|
||||||
|
) %>
|
||||||
|
|
||||||
<h3><%= page_entries_info @proposals %></h3>
|
<h3><%= page_entries_info @proposals %></h3>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<%= form_for(Poll::Booth.new, url: url, as: :booth, method: :get) do |f| %>
|
|
||||||
<div class="small-12 medium-6">
|
|
||||||
<div class="input-group">
|
|
||||||
<%= text_field_tag :search, params[:search], placeholder: t("admin.shared.booths_search.placeholder") %>
|
|
||||||
<div class="input-group-button">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<%= form_for(Debate.new, url: url, as: :debate, method: :get) do |f| %>
|
|
||||||
<div class="small-12 medium-6">
|
|
||||||
<div class="input-group">
|
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.shared.debate_search.placeholder") %>
|
|
||||||
<div class="input-group-button">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<%= form_for(Proposal.new, url: url, as: :proposal, method: :get) do |f| %>
|
|
||||||
<div class="small-12 medium-6">
|
|
||||||
<div class="input-group">
|
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.shared.proposal_search.placeholder") %>
|
|
||||||
<div class="input-group-button">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,15 +1,10 @@
|
|||||||
<h2><%= t("admin.users.index.title") %></h2>
|
<h2><%= t("admin.users.index.title") %></h2>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<%= render Admin::SearchComponent.new(
|
||||||
<%= form_tag admin_users_path, method: :get, remote: true do %>
|
url: admin_users_path,
|
||||||
<div class="input-group">
|
label: t("admin.users.search.placeholder"),
|
||||||
<%= text_field_tag :search, "", placeholder: t("admin.users.search.placeholder") %>
|
remote: true
|
||||||
<div class="input-group-button">
|
) %>
|
||||||
<%= submit_tag t("admin.shared.search.search"), class: "button" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="users">
|
<div id="users">
|
||||||
<%= render "users" %>
|
<%= render "users" %>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
<main>
|
<main>
|
||||||
<h2><%= t("management.proposals.index.title") %></h2>
|
<h2><%= t("management.proposals.index.title") %></h2>
|
||||||
|
|
||||||
<%= render "admin/shared/proposal_search", url: management_proposals_path %>
|
<%= render Admin::SearchComponent.new(
|
||||||
|
url: management_proposals_path,
|
||||||
|
label: t("admin.shared.proposal_search.placeholder")
|
||||||
|
) %>
|
||||||
|
|
||||||
<div class="management-list">
|
<div class="management-list">
|
||||||
<div class="proposals-list">
|
<div class="proposals-list">
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
<h2><%= t("moderation.users.index.title") %></h2>
|
<h2><%= t("moderation.users.index.title") %></h2>
|
||||||
|
|
||||||
<%= form_for(User.new, url: moderation_users_path, as: :user, method: :get) do |f| %>
|
<%= render Admin::SearchComponent.new(
|
||||||
<div class="row">
|
url: moderation_users_path,
|
||||||
<div class="small-12 medium-6 column">
|
label: t("moderation.users.index.search_placeholder")
|
||||||
<%= text_field_tag :search, "", placeholder: t("moderation.users.index.search_placeholder") %>
|
) %>
|
||||||
</div>
|
|
||||||
<div class="small-12 medium-6 column">
|
|
||||||
<%= f.submit t("admin.shared.search.search"), class: "button success" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if @users.present? %>
|
<% if @users.present? %>
|
||||||
<h3><%= page_entries_info @users %></h3>
|
<h3><%= page_entries_info @users %></h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user