OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#55581] link project names to projects
Tobias Dillmann1f554f2a6554
diff --git a/app/components/users/hover_card_component.rb b/app/components/users/hover_card_component.rbindex 21cf2603a28..0473bd9216b 100644--- a/app/components/users/hover_card_component.rb+++ b/app/components/users/hover_card_component.rb@@ -19,20 +19,26 @@ class Users::HoverCardComponent < ApplicationComponent# or# "Member of project1, project2 and 3 more"# The latter string is cut off since the complete list of project names would exceed the allowed `max_length`.- def project_membership_summary(max_length = 50)- project_names = @user.projects.pluck(:name)- return no_project_text if project_names.empty?+ def project_membership_summary(max_length = 40)+ projects = @user.projects+ project_links = linked_project_names(projects)+ return no_project_text if project_links.empty?- cutoff_index = calculate_cutoff_index(project_names, max_length)- build_summary(project_names, cutoff_index)+ cutoff_index = calculate_cutoff_index(projects.map(&:name), max_length)+ build_summary(project_links, cutoff_index)endprivate+ def linked_project_names(projects)+ projects.map { |project| link_to(h(project.name), project_path(project)) }+ end+def no_project_textt("users.memberships.no_results_title_text")end+ # Calculate the index at which to cut off the project names, based on plain text lengthdef calculate_cutoff_index(names, max_length)current_length = 0@@ -46,14 +52,14 @@ class Users::HoverCardComponent < ApplicationComponentnames.size # No cutoff needed -> return the total sizeend- def build_summary(names, cutoff_index)- summary_names = names[0...cutoff_index].join(", ")- remaining_count = names.size - cutoff_index+ def build_summary(links, cutoff_index)+ summary_links = safe_join(links[0...cutoff_index], ", ")+ remaining_count = links.size - cutoff_indexif remaining_count > 0- t("users.memberships.summary_with_more", names: summary_names, count: remaining_count)+ t("users.memberships.summary_with_more", names: summary_links, count: remaining_count).html_safeelse- t("users.memberships.summary", names: summary_names)+ t("users.memberships.summary", names: summary_links).html_safeendendend