Skip to content

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

do not split date-field (combined as in the web), remove duration

as-opf59c5383a0a1
diff --git a/app/models/work_package/exports/formatters/date.rb b/app/models/work_package/exports/formatters/date.rb
new file mode 100644
index 00000000000..21419e8fada
--- /dev/null
+++ b/app/models/work_package/exports/formatters/date.rb
@@ -0,0 +1,42 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+module WorkPackage::Exports
+ module Formatters
+ class Date < ::Exports::Formatters::Default
+ include WorkPackagesHelper
+
+ def self.apply?(name, export_format)
+ name.to_sym == :date && export_format == :pdf
+ end
+
+ def format(work_package, **)
+ work_package_formatted_dates(work_package)
+ end
+ end
+ end
+end
diff --git a/app/models/work_package/pdf_export/export/wp/attributes.rb b/app/models/work_package/pdf_export/export/wp/attributes.rb
index 8e7a07f9c75..c37e873208b 100644
--- a/app/models/work_package/pdf_export/export/wp/attributes.rb
+++ b/app/models/work_package/pdf_export/export/wp/attributes.rb
@@ -216,18 +216,14 @@ module WorkPackage::PDFExport::Export::Wp::Attributes
end
def form_key_to_column_entries(form_key, work_package)
+ return [] if form_key == :bcf_thumbnail
+
if CustomField.custom_field_attribute? form_key
return form_key_custom_field_to_column_entries(form_key, work_package)
end
- if form_key == :date
- column_entries(%i[start_date due_date duration])
- elsif form_key == :bcf_thumbnail
- []
- else
- column_name = ::API::Utilities::PropertyNameConverter.to_ar_name(form_key, context: work_package)
- [column_entry(column_name)]
- end
+ column_name = ::API::Utilities::PropertyNameConverter.to_ar_name(form_key, context: work_package)
+ [column_entry(column_name)]
end
def column_entries(column_names)
diff --git a/config/initializers/export_formats.rb b/config/initializers/export_formats.rb
index ae50c624cb3..2883730b622 100644
--- a/config/initializers/export_formats.rb
+++ b/config/initializers/export_formats.rb
@@ -14,6 +14,7 @@ Rails.application.configure do |application|
formatter WorkPackage, WorkPackage::Exports::Formatters::Currency
formatter WorkPackage, WorkPackage::Exports::Formatters::Costs
formatter WorkPackage, WorkPackage::Exports::Formatters::DoneRatio
+ formatter WorkPackage, WorkPackage::Exports::Formatters::Date
formatter WorkPackage, Exports::Formatters::CustomField
formatter WorkPackage, Exports::Formatters::CustomFieldPdf
diff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
index cc027c520ba..d0e49c3b438 100644
--- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
+++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
@@ -137,7 +137,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
type:,
subject: "Work package 1",
start_date: "2024-05-30",
- due_date: "2024-05-30",
+ due_date: "2025-03-13",
created_at: export_time,
updated_at: export_time,
author: user,
@@ -215,9 +215,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
"Priority", "Normal",
"Version", work_package.version,
"Category", work_package.category,
- "Start date", "05/30/2024",
- "Finish date", "05/30/2024",
- "Duration", "1 d",
+ "Date", "05/30/2024 - 03/13/2025",
"Other",
"Work Package Custom Field Boolean", "Yes",
"Work Package Custom Field Long Text", "foo faa",
@@ -296,7 +294,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
["remainingTime", "9h"],
["version", version.name],
["responsible", user.name],
- ["dueDate", "05/30/2024"],
+ ["dueDate", "03/13/2025"],
["spentTime", "0h"],
["startDate", "05/30/2024"],
["parent", "#{type.name} ##{parent_work_package.id}: #{parent_work_package.name}"],