Add search form to the top of the user list view
This commit is contained in:
parent
30fe6c5b86
commit
4ea868ace7
4 changed files with 82 additions and 51 deletions
|
@ -16,8 +16,8 @@ module Users
|
||||||
@params = params.permit(:status, :ip, :before, :after)
|
@params = params.permit(:status, :ip, :before, :after)
|
||||||
|
|
||||||
users = User.all
|
users = User.all
|
||||||
users = users.where(:status => @params[:status]) if @params[:status]
|
users = users.where(:status => @params[:status]) if @params[:status].present?
|
||||||
users = users.where(:creation_address => @params[:ip]) if @params[:ip]
|
users = users.where(:creation_address => @params[:ip]) if @params[:ip].present?
|
||||||
|
|
||||||
@users_count = users.limit(501).count
|
@users_count = users.limit(501).count
|
||||||
@users_count = I18n.t("count.at_least_pattern", :count => 500) if @users_count > 500
|
@users_count = I18n.t("count.at_least_pattern", :count => 500) if @users_count > 500
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<turbo-frame id="pagination" target="_top" data-turbo="false">
|
<turbo-frame id="pagination" target="_top" data-turbo="false">
|
||||||
|
<% unless @users.empty? %>
|
||||||
<%= form_tag @params, :method => :put do %>
|
<%= form_tag @params, :method => :put do %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@ -45,4 +46,7 @@
|
||||||
<%= submit_tag t(".hide"), :name => "hide", :class => "btn btn-primary" %>
|
<%= submit_tag t(".hide"), :name => "hide", :class => "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% else -%>
|
||||||
|
<p><%= t ".empty" %></p>
|
||||||
|
<% end -%>
|
||||||
</turbo-frame>
|
</turbo-frame>
|
||||||
|
|
|
@ -8,8 +8,26 @@
|
||||||
<h1><%= t(".heading") %></h1>
|
<h1><%= t(".heading") %></h1>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% unless @users.empty? %>
|
<%= form_tag(users_list_path, :method => :get, :data => { "turbo" => true, "turbo-frame" => "pagination", "turbo-action" => "advance" }) do %>
|
||||||
|
<div class="row gx-1">
|
||||||
|
<div class="mb-3 col-md-auto">
|
||||||
|
<%= select_tag :status,
|
||||||
|
options_for_select(User.aasm.states.map(&:name).map { |state| [t(".states.#{state}"), state] }, params[:status]),
|
||||||
|
:include_blank => t(".select_status"),
|
||||||
|
:data => { :behavior => "category_dropdown" },
|
||||||
|
:class => "form-select" %>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 col-md">
|
||||||
|
<%= text_field_tag :ip,
|
||||||
|
params[:ip],
|
||||||
|
:placeholder => t(".ip_address"),
|
||||||
|
:autocomplete => "on",
|
||||||
|
:class => "form-control" %>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 col-md-auto">
|
||||||
|
<%= submit_tag t(".search"), :name => nil, :class => "btn btn-primary" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
<%= render :partial => "page" %>
|
<%= render :partial => "page" %>
|
||||||
<% else %>
|
|
||||||
<p><%= t ".empty" %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
|
@ -2882,13 +2882,22 @@ en:
|
||||||
show:
|
show:
|
||||||
title: Users
|
title: Users
|
||||||
heading: Users
|
heading: Users
|
||||||
empty: No matching users found
|
select_status: Select Status
|
||||||
|
states:
|
||||||
|
pending: Pending
|
||||||
|
active: Active
|
||||||
|
confirmed: Confirmed
|
||||||
|
suspended: Suspended
|
||||||
|
deleted: Deleted
|
||||||
|
ip_address: IP Address
|
||||||
|
search: Search
|
||||||
page:
|
page:
|
||||||
found_users:
|
found_users:
|
||||||
one: "%{count} user found"
|
one: "%{count} user found"
|
||||||
other: "%{count} users found"
|
other: "%{count} users found"
|
||||||
confirm: Confirm Selected Users
|
confirm: Confirm Selected Users
|
||||||
hide: Hide Selected Users
|
hide: Hide Selected Users
|
||||||
|
empty: No matching users found
|
||||||
user:
|
user:
|
||||||
summary_html: "%{name} created from %{ip_address} on %{date}"
|
summary_html: "%{name} created from %{ip_address} on %{date}"
|
||||||
summary_no_ip_html: "%{name} created on %{date}"
|
summary_no_ip_html: "%{name} created on %{date}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue