Upgrade Admin/Users list to use the query system
|Assignee:||Go MAEDA||% Done:|
This patch series that was extracted from Planio introduces a UserQuery
and upgrades the Admin/Users list with corresponding filter, sort and (CSV) export capabilities.
Also introduced are a context menu and an option to delete multiple users at once. The third patch just
adds flash messages to the (single) user deletion operation, for symmetry with the messages rendered by the bulk delete.
User bulk destroy (#37674).
includes a confirmation page that also gives the opportunity to lock
users instead of deleting them.
Patch by Jens Krämer.
Thank you for posting the nice improvement. However, the following error occurred with SQLite.
Error: UsersControllerTest#test_index_with_name_filter: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such function: CONCAT app/controllers/users_controller.rb:54:in `index' lib/redmine/sudo_mode.rb:61:in `sudo_mode' test/functional/users_controller_test.rb:54:in `test_index_with_name_filter' rails test test/functional/users_controller_test.rb:53
Could you update the patch to support SQLite? In my environment, I was able to fix the error with the following code.
--- app/models/user_query.rb.org 2022-09-15 13:34:22.000000000 +0900 +++ app/models/user_query.rb 2022-09-15 13:34:41.000000000 +0900 @@ -134,8 +134,13 @@ def sql_for_name_field(field, operator, value) match = operator == '~' - name_sql = sql_contains("CONCAT(login, ' ', firstname, ' ', lastname)", - value.first, match: match) + if Redmine::Database.sqlite? + name_sql = sql_contains("login || ' ' || firstname || ' ' || lastname", + value.first, match: match) + else + name_sql = sql_contains("CONCAT(login, ' ', firstname, ' ', lastname)", + value.first, match: match) + end emails = EmailAddress.table_name email_sql = <<-SQL
#3 Updated by Jens Krämer 10 days ago
Thank you for looking into this. Attached is the first patch with your solution built in.
This patch uses the "name" filter to search three columns: first name, last name, and email. I think this follows the current search feature. However, I think it may be confusing for users to use the "name" filter to search for email addresses. Actually, neither I nor two of my colleagues could not find a way to search by email until I read the patch.
What about extracting the email address search from the "name" filter and adding a separate "email" filter?
#5 Updated by Jens Krämer 10 days ago
Good point. I indeed tried to stay close to the existing functionality with this combined name filter, but maybe that's not really necessary after all.
I also just noticed that support for the other filter operators like 'starts with' / 'ends with' is still missing. I'll come up with an updated patch soon.
#7 Updated by Jens Krämer 9 days ago
- File 0003-confirm-user-update-deletion.patch added
- File 0002-user-bulk-destroy.patch added
- File 0001-introduces-a-UserQuery-model-for-admin-users.patch added
Please find attached a new series of patches with the following changes:
- reduced number of commits by merging the last commit (auth source filter and column) into the first.
- separate filters for login, firstname, lastname, mail
- fixed the mail filter to support all string operators