Skip to content

Commit

Permalink
Add found users count to users page
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Mar 26, 2024
1 parent 9f8e4fd commit f0d05c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def index
users = users.where(:status => @params[:status]) if @params[:status]
users = users.where(:creation_ip => @params[:ip]) if @params[:ip]

@users_count = users.count
@users, @newer_users_id, @older_users_id = get_page_items(users, :limit => 50)
end
end
Expand Down
34 changes: 24 additions & 10 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
<% unless @users.empty? %>
<%= form_tag do %>
<%= render "shared/pagination",
:newer_key => "users.index.newer",
:older_key => "users.index.older",
:newer_id => @newer_users_id,
:older_id => @older_users_id %>
<div class="row">
<div class="col">
<%= render "shared/pagination",
:newer_key => "users.index.newer",
:older_key => "users.index.older",
:newer_id => @newer_users_id,
:older_id => @older_users_id %>
</div>
<div class="col col-auto">
<%= t ".found_users", :count => @users_count %>
</div>
<div>

<%= hidden_field_tag :status, params[:status] if params[:status] %>
<%= hidden_field_tag :ip, params[:ip] if params[:ip] %>
Expand All @@ -32,11 +39,18 @@
<%= render @users %>
</table>

<%= render "shared/pagination",
:newer_key => "users.index.newer",
:older_key => "users.index.older",
:newer_id => @newer_users_id,
:older_id => @older_users_id %>
<div class="row">
<div class="col">
<%= render "shared/pagination",
:newer_key => "users.index.newer",
:older_key => "users.index.older",
:newer_id => @newer_users_id,
:older_id => @older_users_id %>
</div>
<div class="col col-auto">
<%= t ".found_users", :count => @users_count %>
</div>
<div>

<div>
<%= submit_tag t(".confirm"), :name => "confirm", :class => "btn btn-primary" %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,9 @@ en:
heading: Users
older: "Older Users"
newer: "Newer Users"
found_users:
one: "%{count} user found"
other: "%{count} users found"
summary_html: "%{name} created from %{ip_address} on %{date}"
summary_no_ip_html: "%{name} created on %{date}"
confirm: Confirm Selected Users
Expand Down

0 comments on commit f0d05c2

Please sign in to comment.