Extract users search view to a component
We're going to make this search component more generic, but for now, we're keeping the exact same behavior we had.
This commit is contained in:
10
app/components/admin/search_component.html.erb
Normal file
10
app/components/admin/search_component.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="small-12 medium-6">
|
||||
<%= form_for(User.new, url: url, as: :user, method: :get) do |f| %>
|
||||
<div class="input-group">
|
||||
<%= text_field_tag :name_or_email, params[:name_or_email].to_s, placeholder: t("admin.shared.user_search.placeholder") %>
|
||||
<div class="input-group-button">
|
||||
<%= f.submit t("admin.shared.user_search.button"), class: "button" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
7
app/components/admin/search_component.rb
Normal file
7
app/components/admin/search_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Admin::SearchComponent < ApplicationComponent
|
||||
attr_reader :url
|
||||
|
||||
def initialize(url:)
|
||||
@url = url
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1 @@
|
||||
<div class="small-12 medium-6">
|
||||
<%= form_for(User.new, url: url, as: :user, method: :get) do |f| %>
|
||||
<div class="input-group">
|
||||
<%= text_field_tag :name_or_email, params[:name_or_email].to_s, placeholder: t("admin.shared.user_search.placeholder") %>
|
||||
<div class="input-group-button">
|
||||
<%= f.submit t("admin.shared.user_search.button"), class: "button" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render Admin::SearchComponent.new(url: url) %>
|
||||
|
||||
Reference in New Issue
Block a user