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
[#55088] Gantt PDF export shows superfluous hyphen (-) when start or finish date is missing
Dombi Attila025d3a8d634a
diff --git a/app/models/work_package/pdf_export/gantt/gantt_builder.rb b/app/models/work_package/pdf_export/gantt/gantt_builder.rbindex fd7520da96e..334697cfbe7 100644--- a/app/models/work_package/pdf_export/gantt/gantt_builder.rb+++ b/app/models/work_package/pdf_export/gantt/gantt_builder.rb@@ -743,14 +743,15 @@ module WorkPackage::PDFExport::Ganttdef work_package_info_line_date(work_package)if work_package.start_date == work_package.due_date- format_pdf_date(work_package.start_date)+ format_pdf_date(work_package, :start_date)else- "#{format_pdf_date(work_package.start_date)} - #{format_pdf_date(work_package.due_date)}"+ "#{format_pdf_date(work_package, :start_date)} - #{format_pdf_date(work_package, :due_date)}"endend- def format_pdf_date(date)- date.nil? ? "" : format_date(date)+ def format_pdf_date(work_package, date_field)+ date = work_package.send(date_field)+ date.nil? ? I18n.t("label_no_#{date_field}") : format_date(date)end# Builds the shape for the given work packagediff --git a/config/locales/en.yml b/config/locales/en.ymlindex fc2c62e4f17..52604c153cc 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2285,6 +2285,8 @@ en:label_next_week: "Next week"label_no_change_option: "(No change)"label_no_data: "No data to display"+ label_no_due_date: "no finish date"+ label_no_start_date: "no start date"label_no_parent_page: "No parent page"label_nothing_display: "Nothing to display"label_nobody: "nobody"diff --git a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_gantt_spec.rb b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_gantt_spec.rbindex a1040f3d8ef..9ada0256b7a 100644--- a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_gantt_spec.rb+++ b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_gantt_spec.rb@@ -155,7 +155,9 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf doif work_package.start_date == work_package.due_dateformat_date(work_package.start_date)else- "#{format_date(work_package.start_date)} - #{format_date(work_package.due_date)}"+ formatted_start_date = format_date(work_package.start_date) || "no start date"+ formatted_due_date = format_date(work_package.due_date) || "no start date"+ "#{formatted_start_date} - #{formatted_due_date}"endend