Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#55088] Gantt PDF export shows superfluous hyphen (-) when dates are missing #16413

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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