From b995014c495b36102f36ec80618f50f3763bcd6f Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 6 Feb 2020 08:19:13 +0000 Subject: Allow adding user groups as watchers for issues (#4511). Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@19498 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/avatars_helper.rb | 6 ++++++ app/helpers/issues_helper.rb | 7 +++++-- app/helpers/watchers_helper.rb | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 7e2a1fffd..49be006a8 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -51,6 +51,8 @@ module AvatarsHelper gravatar(email.to_s.downcase, options) rescue nil elsif user.is_a?(AnonymousUser) anonymous_avatar(options) + elsif user.is_a?(Group) + group_avatar(options) else nil end @@ -72,4 +74,8 @@ module AvatarsHelper def anonymous_avatar(options={}) image_tag 'anonymous.png', GravatarHelper::DEFAULT_OPTIONS.except(:default, :rating, :ssl).merge(options) end + + def group_avatar(options={}) + image_tag 'group.png', GravatarHelper::DEFAULT_OPTIONS.except(:default, :rating, :ssl).merge(options) + end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 2ea81d566..0f327b77e 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -365,8 +365,11 @@ module IssuesHelper # on the new issue form def users_for_new_issue_watchers(issue) users = issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE} - if issue.project.users.count <= 20 - users = (users + issue.project.users.sort).uniq + project = issue.project + scope_users = project.users + scope_groups = project.principals.merge(Group.givable) + if scope_users.count + scope_groups.count <= 20 + users = (users + scope_users.sort + scope_groups.sort).uniq end users end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index dab5e6b76..ac732c339 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -47,7 +47,7 @@ module WatchersHelper def watchers_list(object) remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".to_sym, object.project) content = ''.html_safe - lis = object.watcher_users.preload(:email_address).collect do |user| + lis = object.watcher_users.collect do |user| s = ''.html_safe s << avatar(user, :size => "16").to_s s << link_to_user(user, :class => 'user') -- cgit v1.2.3