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
text ellipsis for work package subject cell
as-op6db6058691e4
diff --git a/app/models/work_package/pdf_export/common/common.rb b/app/models/work_package/pdf_export/common/common.rbindex 7a6c07fc119..63c055a4004 100644--- a/app/models/work_package/pdf_export/common/common.rb+++ b/app/models/work_package/pdf_export/common/common.rb@@ -164,6 +164,13 @@ module WorkPackage::PDFExport::Common::Commonmeasure_text_height(line, text_style)end+ def ellipsis_if_longer(text, available_width, text_style)+ title_text_width = measure_text_width(text, text_style)+ return text if title_text_width < available_width++ truncate_ellipsis(text, available_width, text_style)+ end+def truncate_ellipsis(text, available_width, text_style)line = text.dupwhile line.present? && (measure_text_width("#{line}...", text_style) > available_width)diff --git a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rbindex 6fe23c27c92..1af613255cc 100644--- a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb+++ b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb@@ -123,6 +123,10 @@ class CostQuery::PDF::TimesheetGeneratorwith_times_column? ? [80, 193, 80, 70, 100] : [80, 270, 70, 100]end+ def table_column_workpackage_text_width+ (with_times_column? ? 193 : 270) - 10 # - padding+ end+def table_widthtable_columns_widths.sumend@@ -131,6 +135,10 @@ class CostQuery::PDF::TimesheetGeneratorwith_times_column? ? 4 : 3end+ def table_cell_style_font_size+ 12+ end+# rubocop:disable Metrics/AbcSizedef build_table(rows)pdf.make_table(@@ -139,6 +147,7 @@ class CostQuery::PDF::TimesheetGeneratorwidth: table_width,column_widths: table_columns_widths,cell_style: {+ size: table_cell_style_font_size,border_color: "BBBBBB",border_width: 0.5,borders: %i[top bottom],@@ -185,6 +194,7 @@ class CostQuery::PDF::TimesheetGeneratorendgroupsend+# rubocop:enable Metrics/AbcSizedef write_table(user_id, entries)@@ -193,8 +203,8 @@ class CostQuery::PDF::TimesheetGenerator# for easier handling existing rowspan cells are grouped as one rowgrouped_rows = split_group_rows(rows)# start a new page if the username would be printed alone at the end of the page- pdf.start_new_page if available_space_from_bottom < grouped_rows[0][:height] + grouped_rows[1][:height] + 20- write_user(user_id)+ pdf.start_new_page if available_space_from_bottom < grouped_rows[0][:height] + grouped_rows[1][:height] + username_height+ write_username(user_id)write_grouped_tables(grouped_rows)end@@ -266,7 +276,11 @@ class CostQuery::PDF::TimesheetGeneratorpdf.move_down(2)end- def write_user(user_id)+ def username_height+ 20 + 10+ end++ def write_username(user_id)pdf.formatted_text([{ text: user_name(user_id), size: 20 }])pdf.move_down(10)end@@ -280,7 +294,8 @@ class CostQuery::PDF::TimesheetGeneratorenddef wp_subject(wp_id)- WorkPackage.find(wp_id).subject+ text = WorkPackage.find(wp_id).subject+ ellipsis_if_longer(text, table_column_workpackage_text_width, { size: table_cell_style_font_size })enddef format_duration(hours)