Project

General

Profile

Modify user list in assign user field

Added by Jurek Burek about 1 month 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? :)