diff options
author | Go MAEDA <maeda@farend.jp> | 2021-07-19 15:13:58 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2021-07-19 15:13:58 +0000 |
commit | 56a7fd22c7af2119980c6dba42606e140383b878 (patch) | |
tree | 9432b544b8686b1094a26c75dc28fee4a80edec8 /app/helpers/application_helper.rb | |
parent | 482656fb2c09e9e456a3e006ceaf78d0c6f33ee5 (diff) | |
download | redmine-56a7fd22c7af2119980c6dba42606e140383b878.tar.gz redmine-56a7fd22c7af2119980c6dba42606e140383b878.zip |
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
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 57f3e488b..ae0094872 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 |