Modify user list in assign user field
Added by Jurek Burek 3 months ago
I'm writing a plugin in Redmine and want to add the number of points to the list of users available to select in the "assign to" field in a task. Something like "John Power - 2 points." Once, I managed to create such a list, but it was a new element in the form, which is not what I'm aiming for here.
In summary, I want to modify the user list and add the calculated number of points for each user. I'm currently trying to do this using hooks:
module UserPoints class Hooks < Redmine::Hook::ViewListener def view_issues_form_details_bottom(context = {}) issue = context[:issue] assignable_users = issue.assignable_users users_points = assignable_users.map do |user| user.lastname = "#{user.lastname} - 2 points" user end context[:assignable_users] = users_points end end end
When i puts users_points i see changes but unfortunately (after restarting Redmine), I don't see any changes. Can you suggest what I might be doing wrong? :)
Replies (5)
RE: Modify user list in assign user field - Added by Jurek Burek about 2 months ago
Please assist. I've tried several other approaches. Some generate nothing, others throw errors, and the best ones simply add a new select to the form instead of modifying the original 'assign to' select.
RE: Modify user list in assign user field - Added by Ivan Ivanov about 2 months ago
Hi. Maybe the problem can be solved using custom fields?
RE: Modify user list in assign user field - Added by Jurek Burek about 1 month ago
This is an idea, but I have to use the system 'assign to' field, which is utilized across all views and reports throughout Redmine.
What’s interesting is that when I print the 'users_points' variable on the server, I get a collection with the points added. However, the changes are not visible in the select field on the form, only the name and surname remain there.
RE: Modify user list in assign user field - Added by Ivan Ivanov about 1 month ago
Could you share the code, please?
RE: Modify user list in assign user field - Added by Ivan Ivanov about 1 month ago
Anyway, here's a link to some info on hooks. Maybe it'll give you an idea of what you're doing.