]> source.dussan.org Git - redmine.git/commitdiff
Display avatar on add watchar dialog (#32976).
authorGo MAEDA <maeda@farend.jp>
Tue, 31 Mar 2020 09:30:47 +0000 (09:30 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 31 Mar 2020 09:30:47 +0000 (09:30 +0000)
Patch by Takenori TAKAKI.

git-svn-id: http://svn.redmine.org/redmine/trunk@19626 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
public/stylesheets/application.css
test/helpers/application_helper_test.rb
test/helpers/groups_helper_test.rb
test/helpers/members_helper_test.rb

index 2fed8ee91fee42cd1df4a12cad18e2b54513d456..f94732fc6fdaef66bb9f09700367d60660314b72 100644 (file)
@@ -579,7 +579,10 @@ module ApplicationHelper
   def principals_check_box_tags(name, principals)
     s = +''
     principals.each do |principal|
-      s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } <span class='name icon icon-#{principal.class.name.downcase}'></span>#{h principal}</label>\n"
+      s << content_tag('label',
+                       check_box_tag(name, principal.id, false, :id => nil) +
+                       (avatar(principal, :size => 16).presence || content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}")) +
+                       principal)
     end
     s.html_safe
   end
index 8f92c8e986421edd046a5d4eea446745e4b955e4..73e8b34841b5bf210e960d6285e0f0ae4e394207 100644 (file)
@@ -415,6 +415,7 @@ td.center {text-align:center;}
 
 #watchers select {width: 95%; display: block;}
 #watchers img.gravatar {margin: 0 4px 2px 0;}
+#users_for_watcher img.gravatar {padding-bottom: 2px; margin-right: 4px;}
 
 span#watchers_inputs {overflow:auto; display:block;}
 span.search_for_watchers {display:block;}
index 81e20c1b6f5bbbe8ed7656ec108c0aeebdd2f0b3..d076aba86f6ce999aef511106ae6e30c115f22f4 100644 (file)
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
 class ApplicationHelperTest < Redmine::HelperTest
   include ERB::Util
   include Rails.application.routes.url_helpers
+  include AvatarsHelper
 
   fixtures :projects, :enabled_modules,
            :users, :email_addresses,
@@ -1704,6 +1705,31 @@ class ApplicationHelperTest < Redmine::HelperTest
     end
   end
 
+  def test_principals_check_box_tag_with_avatar
+    principals = [User.find(1), Group.find(10)]
+    with_settings :gravatar_enabled => '1' do
+      tags = principals_check_box_tags("watcher[user_ids][]", principals)
+      principals.each do |principal|
+        assert_include avatar(principal, :size => 16), tags
+        assert_not_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags
+      end
+    end
+  end
+
+  def test_principals_check_box_tag_without_avatar
+    principals = [User.find(1), Group.find(10)]
+    Setting.gravatar_enabled = '1'
+    avatar_tags = principals.collect{|p| avatar(p, :size => 16) }
+
+    with_settings :gravatar_enabled => '0' do
+      tags = principals_check_box_tags(name, principals)
+      principals.each_with_index do |principal, i|
+        assert_not_include avatar_tags[i], tags
+        assert_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags
+      end
+    end
+  end
+
   def test_principals_options_for_select_with_users
     User.current = nil
     users = [User.find(2), User.find(4)]
index 0865daa5654ff9e78dabb2ab2503be229a4bbcfa..8424cc450ad874f4323b54fa9e8ace73e47882d1 100644 (file)
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
 class GroupsHelperTest < Redmine::HelperTest
   include ERB::Util
   include GroupsHelper
+  include AvatarsHelper
   include Rails.application.routes.url_helpers
 
   fixtures :users
index e4f2e1541e5093df94fd17bb8153e6241ee8ec5f..8858ab57d21cd25cf282c568a296bd46cdb30306 100644 (file)
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__)
 class MembersHelperTest < Redmine::HelperTest
   include ERB::Util
   include MembersHelper
+  include AvatarsHelper
   include Rails.application.routes.url_helpers
 
   fixtures :projects, :users, :members, :member_roles,