Skip to content

Commit

Permalink
[#55088] Gantt PDF export shows superfluous hyphen (-) when start or …
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Aug 12, 2024
1 parent 806ba8f commit 025d3a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/models/work_package/pdf_export/gantt/gantt_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,15 @@ def work_package_info_line(work_package)

def 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)}"
end
end

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 package
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def wp_title_dates(work_package)
if work_package.start_date == work_package.due_date
format_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}"
end
end

Expand Down

0 comments on commit 025d3a8

Please sign in to comment.