diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 92c852f9c15..780ce0887a7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -63,6 +63,8 @@ def set_anonymized_view def list letter = params[:letter] search_by = params[:search_by] + @pagination_options = pagination_options + @per_page = @pagination_options[params[:per_page]] # If search parameters present if letter.present? && search_by.present? case search_by.to_i @@ -259,7 +261,6 @@ def pagination_options # For filtering the users list with proper search and pagination. def paginate_list paginate_options = pagination_options - # If the above hash does not have a value for the key, # it means that we need to show all the users on the page # @@ -270,15 +271,15 @@ def paginate_list @search_by = params[:search_by] # Sets the number of users to display per page based on the 'per_page' parameter from the request. - # If no 'per_page' parameter is provided, it defaults to '4', which corresponds to displaying all users on one page. - @per_page = params[:per_page] || '4' + # If no 'per_page' parameter is provided, it defaults to '2', which corresponds to displaying 50 users on one page. + @per_page = params[:per_page] # search for corresponding users # users = User.search_users(role, user_id, letter, @search_by) # paginate users = if paginate_options[@per_page.to_s].nil? # displaying all - no pagination - User.paginate(page: params[:page], per_page: User.count) + User.paginate(page: params[:page], per_page: paginate_options['1']) else # some pagination is active - use the per_page User.paginate(page: params[:page], per_page: paginate_options[@per_page.to_s]) end diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 57422087b6b..f2f7731119a 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -6,18 +6,30 @@ <% end %> -<%= form_tag :action => 'list', :paginate_show => '1', :num_users => @per_page do %> - <%= label_tag :letter, 'Search users: ' %><%= text_field_tag(:letter,params[:letter]) %> -<%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> -<%= submit_tag("Search") %> -<% end %> +<%= form_tag :action => 'list' do %> + <%= label_tag :letter, 'Search users: ' %> + <%= text_field_tag(:letter, params[:letter]) %> + <%= select_tag(:search_by, options_for_select([['Username', 1], ['Full name', 2], ['Email', 3]])) %> + <%= submit_tag("Search") %> -<%= render :partial => 'links' %> +<%= label_tag :per_page, 'Users per page: ' %> + <%= select_tag(:per_page, options_for_select(@pagination_options.map { |key, value| ["#{value == User.count ? 'All' : value}", key] }, selected: params[:per_page] || '1'), onchange: 'this.form.submit()') %> +<% end %>
- + + + + + + + + + + + <% @paginated_users.each do |user| %> <% if (params[:show] != 'true' && !user.username(session[:ip]).include?("_hidden")) || params[:show] == 'true'%> @@ -35,10 +47,6 @@ <% end -%>
E-mail on ...
User NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
User NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
-
- -
-<%#= render :partial => 'shared_scripts/pages' %>
<%= will_paginate @paginated_users, :inner_window => 1, :outer_window => 1, :params => {:num_versions => @per_page}%> @@ -53,5 +61,4 @@ <%= link_to 'New user',:role => "Student", :action => 'new' %> | <%= link_to 'Import users', :controller=>'import_file', :action=>'start', :model => 'User', :expected_fields => 'username  |  full name (first [middle] last)  |  e-mail address' %> | <%= link_to 'Export users', :controller=>'export_file',:action=>'start',:model=> 'User',:id=> 1 %> -

diff --git a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb index 2be1fe111f1..007628b6e8b 100644 --- a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb +++ b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb @@ -3,6 +3,6 @@ def change rename_column :users, :name, :username rename_column :account_requests, :name, :username rename_column :users, :fullname, :name - rename_column :account_requests, :fullname, :username + rename_column :account_requests, :fullname, :name end end \ No newline at end of file