mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-11 13:15:20 +00:00
Add link from group name to group page on project overview page (#12795).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@21073 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
482656fb2c
commit
56a7fd22c7
@ -51,17 +51,28 @@ module ApplicationHelper
|
||||
|
||||
# Displays a link to user's account page if active
|
||||
def link_to_user(user, options={})
|
||||
if user.is_a?(User)
|
||||
name = h(user.name(options[:format]))
|
||||
if user.active? || (User.current.admin? && user.logged?)
|
||||
only_path = options[:only_path].nil? ? true : options[:only_path]
|
||||
link_to name, user_url(user, :only_path => only_path), :class => user.css_classes
|
||||
else
|
||||
name
|
||||
user.is_a?(User) ? link_to_principal(user, options) : h(user.to_s)
|
||||
end
|
||||
|
||||
# Displays a link to user's account page or group page
|
||||
def link_to_principal(principal, options={})
|
||||
only_path = options[:only_path].nil? ? true : options[:only_path]
|
||||
case principal
|
||||
when User
|
||||
name = h(principal.name(options[:format]))
|
||||
if principal.active? || (User.current.admin? && principal.logged?)
|
||||
url = user_url(principal, :only_path => only_path)
|
||||
css_classes = principal.css_classes
|
||||
end
|
||||
when Group
|
||||
name = h(principal.to_s)
|
||||
url = group_url(principal, :only_path => only_path)
|
||||
css_classes = "group icon icon-#{principal.class.name.downcase}"
|
||||
else
|
||||
h(user.to_s)
|
||||
name = h(principal.to_s)
|
||||
end
|
||||
|
||||
url ? link_to(name, url, :class => css_classes) : name
|
||||
end
|
||||
|
||||
# Displays a link to edit group page if current user is admin
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div class="members box">
|
||||
<h3 class="icon icon-group"><%=l(:label_member_plural)%></h3>
|
||||
<% @principals_by_role.keys.sort.each do |role| %>
|
||||
<p><span class="label"><%= role %>:</span> <%= @principals_by_role[role].sort.collect{|p| link_to_user p}.join(", ").html_safe %></p>
|
||||
<p><span class="label"><%= role %>:</span> <%= @principals_by_role[role].sort.collect{|p| link_to_principal p}.join(", ").html_safe %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@ -1708,6 +1708,17 @@ class ApplicationHelperTest < Redmine::HelperTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_link_to_principal_should_link_to_user
|
||||
user = User.find(2)
|
||||
assert_equal link_to_user(user), link_to_principal(user)
|
||||
end
|
||||
|
||||
def test_link_to_principal_should_link_to_group
|
||||
group = Group.find(10)
|
||||
result = link_to('A Team', '/groups/10', :class => 'group icon icon-group')
|
||||
assert_equal result, link_to_principal(group)
|
||||
end
|
||||
|
||||
def test_link_to_group_should_return_only_group_name_for_non_admin_users
|
||||
User.current = nil
|
||||
group = Group.find(10)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user