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

[#48420] Sums table in work plan pdf export (#12792)

Andrej Sandorf988f45d3c418
diff --git a/app/models/exports/concerns/csv.rb b/app/models/exports/concerns/csv.rb
index 9c6de931150..e7a64e06854 100644
--- a/app/models/exports/concerns/csv.rb
+++ b/app/models/exports/concerns/csv.rb
@@ -78,7 +78,7 @@ module Exports
end
def format_csv(record, attribute)
- format_attribute(record, attribute, array_separator: '; ')
+ format_attribute(record, attribute, :csv, array_separator: '; ')
end
def csv_export_filename
diff --git a/app/models/exports/exporter.rb b/app/models/exports/exporter.rb
index 6f1d05b74a6..0d772aaf8e4 100644
--- a/app/models/exports/exporter.rb
+++ b/app/models/exports/exporter.rb
@@ -63,12 +63,12 @@ module Exports
protected
- def formatter_for(attribute)
- ::Exports::Register.formatter_for(model, attribute)
+ def formatter_for(attribute, export_format)
+ ::Exports::Register.formatter_for(model, attribute, export_format)
end
- def format_attribute(object, attribute, **options)
- formatter = formatter_for(attribute)
+ def format_attribute(object, attribute, export_format, **options)
+ formatter = formatter_for(attribute, export_format)
formatter.format(object, **options)
end
end
diff --git a/app/models/exports/formatters/custom_field.rb b/app/models/exports/formatters/custom_field.rb
index 393d9e42a76..228a2f43595 100644
--- a/app/models/exports/formatters/custom_field.rb
+++ b/app/models/exports/formatters/custom_field.rb
@@ -1,7 +1,7 @@
module Exports
module Formatters
class CustomField < Default
- def self.apply?(attribute)
+ def self.apply?(attribute, _export_format)
attribute.start_with?('cf_')
end
diff --git a/app/models/exports/formatters/default.rb b/app/models/exports/formatters/default.rb
index 64318d49570..8ff985772fe 100644
--- a/app/models/exports/formatters/default.rb
+++ b/app/models/exports/formatters/default.rb
@@ -9,7 +9,7 @@ module Exports
@attribute = attribute
end
- def self.apply?(_attribute)
+ def self.apply?(_attribute, _export_format)
false
end
@@ -21,7 +21,12 @@ module Exports
# Takes a resource and an attribute and returns the value to be exported.
def format(object, **options)
value = retrieve_value(object)
+ format_value(value)
+ end
+ ##
+ # Takes a value and returns the formatted value to be exported.
+ def format_value(value)
case value
when Date
format_date value
diff --git a/app/models/exports/register.rb b/app/models/exports/register.rb
index f07f2edb57a..f4f2489ab12 100644
--- a/app/models/exports/register.rb
+++ b/app/models/exports/register.rb
@@ -75,8 +75,8 @@ module Exports
singles[model.to_s].detect { |exporter| exporter.key == format }
end
- def formatter_for(model, attribute)
- formatter = formatters[model.to_s].find { |f| f.apply? attribute } || ::Exports::Formatters::Default
+ def formatter_for(model, attribute, export_format)
+ formatter = formatters[model.to_s].find { |f| f.apply? attribute, export_format } || ::Exports::Formatters::Default
formatter.new(attribute)
end
end
diff --git a/app/models/projects/exports/formatters/description.rb b/app/models/projects/exports/formatters/description.rb
index f76d6164e58..a6147b57cff 100644
--- a/app/models/projects/exports/formatters/description.rb
+++ b/app/models/projects/exports/formatters/description.rb
@@ -28,7 +28,7 @@
module Projects::Exports
module Formatters
class Description < ::Exports::Formatters::Default
- def self.apply?(attribute)
+ def self.apply?(attribute, _export_format)
attribute.to_sym == :description
end
diff --git a/app/models/projects/exports/formatters/status.rb b/app/models/projects/exports/formatters/status.rb
index fb59b25a699..2b62cd69342 100644
--- a/app/models/projects/exports/formatters/status.rb
+++ b/app/models/projects/exports/formatters/status.rb
@@ -28,7 +28,7 @@
module Projects::Exports
module Formatters
class Status < ::Exports::Formatters::Default
- def self.apply?(attribute)
+ def self.apply?(attribute, _export_format)
%i[project_status status].include?(attribute.to_sym)
end
diff --git a/app/models/work_package/exports/formatters/costs.rb b/app/models/work_package/exports/formatters/costs.rb
index c9ff20a5ae7..b83b41cd696 100644
--- a/app/models/work_package/exports/formatters/costs.rb
+++ b/app/models/work_package/exports/formatters/costs.rb
@@ -28,8 +28,8 @@
module WorkPackage::Exports
module Formatters
class Costs < ::Exports::Formatters::Default
- def self.apply?(column)
- column.is_a? ::Costs::QueryCurrencyColumn
+ def self.apply?(name, export_format)
+ %i[material_costs labor_costs overall_costs].include?(name.to_sym) && export_format == :csv
end
def format_options
diff --git a/app/models/work_package/exports/formatters/currency.rb b/app/models/work_package/exports/formatters/currency.rb
new file mode 100644
index 00000000000..2f59f2531ef
--- /dev/null
+++ b/app/models/work_package/exports/formatters/currency.rb
@@ -0,0 +1,40 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Currency < ::Exports::Formatters::Default
+ def self.apply?(name, export_format)
+ %i[material_costs labor_costs overall_costs].include?(name.to_sym) && export_format == :pdf
+ end
+
+ def format_value(value)
+ value.nil? || value.zero? ? '' : number_to_currency(value)
+ end
+ end
+ end
+end
diff --git a/app/models/work_package/exports/formatters/days.rb b/app/models/work_package/exports/formatters/days.rb
new file mode 100644
index 00000000000..22bf2b15faa
--- /dev/null
+++ b/app/models/work_package/exports/formatters/days.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Days < ::Exports::Formatters::Default
+ def self.apply?(name, export_format)
+ name.to_sym == :duration && export_format == :pdf
+ end
+
+ def format_value(value)
+ formatted_days(value)
+ end
+
+ private
+
+ def formatted_days(value)
+ value.nil? ? '' : "#{value} #{I18n.t('export.units.days')}"
+ end
+ end
+ end
+end
diff --git a/app/models/work_package/exports/formatters/estimated_hours.rb b/app/models/work_package/exports/formatters/estimated_hours.rb
index 97ce4d962c2..f89e2a238ef 100644
--- a/app/models/work_package/exports/formatters/estimated_hours.rb
+++ b/app/models/work_package/exports/formatters/estimated_hours.rb
@@ -28,14 +28,12 @@
module WorkPackage::Exports
module Formatters
class EstimatedHours < ::Exports::Formatters::Default
- def self.apply?(name)
- name == :estimated_hours
+ def self.apply?(name, _export_format)
+ name.to_sym == :estimated_hours
end
- ##
- # Takes a WorkPackage and a QueryColumn and returns the value to be exported.
def format(work_package, **)
- estimated_hours = work_package.estimated_hours
+ estimated_hours = formatted_hours(work_package.estimated_hours)
derived_hours = formatted_derived_hours(work_package)
if estimated_hours.nil? || derived_hours.nil?
@@ -45,11 +43,19 @@ module WorkPackage::Exports
"#{estimated_hours} #{derived_hours}"
end
+ def format_value(value)
+ formatted_hours(value)
+ end
+
private
+ def formatted_hours(value)
+ value.nil? ? nil : "#{value} #{I18n.t('export.units.hours')}"
+ end
+
def formatted_derived_hours(work_package)
if (derived_estimated_value = work_package.derived_estimated_hours)
- "(#{derived_estimated_value})"
+ "(#{formatted_hours(derived_estimated_value)})"
end
end
end
diff --git a/app/models/work_package/exports/formatters/hours.rb b/app/models/work_package/exports/formatters/hours.rb
new file mode 100644
index 00000000000..bd6c047735e
--- /dev/null
+++ b/app/models/work_package/exports/formatters/hours.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Hours < ::Exports::Formatters::Default
+ def self.apply?(name, export_format)
+ %i[remaining_hours spent_hours].include?(name.to_sym) && export_format == :pdf
+ end
+
+ def format_value(value)
+ formatted_hours(value)
+ end
+
+ private
+
+ def formatted_hours(value)
+ value.nil? ? '' : "#{value} #{I18n.t('export.units.hours')}"
+ end
+ end
+ end
+end
diff --git a/app/models/work_package/pdf_export/common.rb b/app/models/work_package/pdf_export/common.rb
index 306fac9b7ce..180cba35b50 100644
--- a/app/models/work_package/pdf_export/common.rb
+++ b/app/models/work_package/pdf_export/common.rb
@@ -83,17 +83,24 @@ module WorkPackage::PDFExport::Common
end
end
- def get_column_value(work_package, column)
- formatter = formatter_for(column)
+ def get_column_value(work_package, column_name)
+ formatter = formatter_for(column_name, :pdf)
formatter.format(work_package)
end
- def get_column_value_cell(work_package, column)
- value = escape_tags(get_column_value(work_package, column))
- return get_id_column_cell(work_package, value) if column == :id
- return get_subject_column_cell(work_package, value) if with_descriptions? && column == :subject
+ def get_column_value_cell(work_package, column_name)
+ value = get_column_value(work_package, column_name)
+ return get_id_column_cell(work_package, value) if column_name == :id
+ return get_subject_column_cell(work_package, value) if with_descriptions? && column_name == :subject
- value
+ escape_tags(value)
+ end
+
+ def get_formatted_value(value, column_name)
+ return '' if value.nil?
+
+ formatter = formatter_for(column_name, :pdf)
+ formatter.format_value(value)
end
def escape_tags(value)
@@ -107,7 +114,7 @@ module WorkPackage::PDFExport::Common
end
def get_subject_column_cell(work_package, value)
- make_link_anchor(work_package.id, value)
+ make_link_anchor(work_package.id, escape_tags(value))
end
def make_link_href_cell(href, caption)
@@ -187,10 +194,23 @@ module WorkPackage::PDFExport::Common
end
end
+ def get_total_sums
+ query.display_sums? ? (query.results.all_total_sums || {}) : {}
+ end
+
+ def get_group_sums(group)
+ @group_sums ||= query.results.all_group_sums
+ @group_sums[group] || {}
+ end
+
def with_descriptions?
options[:show_report]
end
+ def with_sums_table?
+ query.display_sums?
+ end
+
def with_attachments?
options[:show_images]
end
diff --git a/app/models/work_package/pdf_export/overview_table.rb b/app/models/work_package/pdf_export/overview_table.rb
index e9e5c220f2d..420ee4febb7 100644
--- a/app/models/work_package/pdf_export/overview_table.rb
+++ b/app/models/work_package/pdf_export/overview_table.rb
@@ -48,8 +48,8 @@ module WorkPackage::PDFExport::OverviewTable
end
end
- def table_columns_objects
- @table_columns_objects ||= limit_table_columns_objects
+ def overview_columns_objects
+ @overview_columns_objects ||= limit_table_columns_objects
end
def limit_table_columns_objects
@@ -59,10 +59,9 @@ module WorkPackage::PDFExport::OverviewTable
end
def table_column_widths
- widths = table_columns_objects.map do |col|
+ widths = overview_columns_objects.map do |col|
col.name == :subject || text_column?(col) ? 4.0 : 1.0
end
- widths.unshift 1.0 if with_descriptions?
ratio = pdf.bounds.width / widths.sum
widths.map { |w| w * ratio }
end
@@ -80,96 +79,59 @@ module WorkPackage::PDFExport::OverviewTable
def write_table!(work_packages, id_wp_meta_map, sums)
rows = build_table_rows(work_packages, id_wp_meta_map, sums)
- pdf_table_auto_widths(rows, table_column_widths, table_options) do |table|
- format_sum_cells table.cells.columns(0..-1).rows(-1) if query.display_sums?
- end
+ pdf_table_auto_widths(rows, table_column_widths, overview_table_options)
end
- def table_options
+ def overview_table_options
{ header: true, cell_style: styles.overview_table_cell.merge({ inline_format: true }) }
end
- def format_sum_cells(sums_cells)
- sums_style = styles.overview_table_sums_cell
- sums_cells.each do |cell|
- apply_cell_style cell, sums_style
- end
- end
-
- def apply_cell_style(cell, cell_style)
- cell.background_color = cell_style[:background_color]
- cell.font_style = cell_style[:font]
- cell.text_color = cell_style[:color]
- cell.size = cell_style[:size]
- end
-
- def get_total_sums
- query.results.all_total_sums if query.display_sums?
- end
-
- def get_group_sums(group)
- return nil unless query.display_sums?
-
- @group_sums ||= query.results.all_group_sums
- @group_sums[group]
- end
-
def build_table_rows(work_packages, id_wp_meta_map, sums)
rows = work_packages.map do |work_package|
build_table_row(work_package, id_wp_meta_map)
end
rows.unshift build_header_row
- rows.push build_sum_row(sums) unless sums.nil?
+ rows.push build_overview_sum_row(sums) if query.display_sums?
rows
end
def build_table_row(work_package, id_wp_meta_map)
- row = table_columns_objects.map do |col|
+ cell_style = styles.overview_table_cell
+ overview_columns_objects.map do |col|
content = get_column_value_cell work_package, col.name
- col.name == :subject ? build_subject_cell(content, work_package, id_wp_meta_map) : build_column_cell(content)
+ if col.name == :subject
+ build_subject_cell(content, work_package, id_wp_meta_map)
+ else
+ pdf.make_cell(content, cell_style)
+ end
end
- row.unshift build_nr_cell(work_package, id_wp_meta_map) if with_descriptions?
- row
- end
-
- def build_column_cell(content)
- pdf.make_cell(content, styles.overview_table_cell)
- end
-
- def build_nr_cell(work_package, id_wp_meta_map)
- content = "#{id_wp_meta_map[work_package.id][:level_path].join('.')}."
- content = make_link_anchor(work_package.id, content)
- build_column_cell(content)
end
def build_subject_cell(content, work_package, id_wp_meta_map)
- opts = styles.overview_table_cell
- padding_left = opts.fetch(:padding_left, 0)
+ cell_style = styles.overview_table_cell
+ padding_left = cell_style.fetch(:padding_left, 0)
if query.show_hierarchies
level = id_wp_meta_map[work_package.id][:level_path].length
padding_left = (styles.overview_table_subject_indent * level) if level > 1
end
- pdf.make_cell(content, opts.merge({ padding_left: }))
+ pdf.make_cell(content, cell_style.merge({ padding_left: }))
end
def build_header_row
header_style = styles.overview_table_header_cell
- row = table_columns_objects.map do |col|
+ overview_columns_objects.map do |col|
content = (col.caption || '').upcase
- build_header_cell(content, header_style)
+ pdf.make_cell(content, header_style)
end
- row.unshift build_header_cell('#', header_style) if with_descriptions?
- row
- end
-
- def build_header_cell(content, opts)
- pdf.make_cell(content, opts)
end
- def build_sum_row(sums)
- sum_row = table_columns_objects.map { |col| sums[col].to_s }
- sum_row.unshift '' if with_descriptions?
- sum_row[0] = I18n.t('js.label_sum')
+ def build_overview_sum_row(sums)
+ sums_style = styles.overview_table_sums_cell
+ sum_row = overview_columns_objects.map do |col|
+ content = get_formatted_value(sums[col], col.name)
+ pdf.make_cell(content, sums_style)
+ end
+ sum_row[0] = pdf.make_cell(I18n.t('js.label_sum'), sums_style)
sum_row
end
end
diff --git a/app/models/work_package/pdf_export/sums_table.rb b/app/models/work_package/pdf_export/sums_table.rb
new file mode 100644
index 00000000000..c2918a7e35d
--- /dev/null
+++ b/app/models/work_package/pdf_export/sums_table.rb
@@ -0,0 +1,113 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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::PDFExport::SumsTable
+ def write_work_packages_sums!(work_packages)
+ return unless has_summable_column?
+
+ write_optional_page_break
+ write_sums_title!
+ with_margin(styles.overview_table_margins) do
+ write_sums_table!(work_packages)
+ end
+ end
+
+ private
+
+ def has_summable_column?
+ !sums_columns_objects.empty?
+ end
+
+ def write_sums_title!
+ with_margin(styles.page_heading_margins) do
+ pdf.formatted_text([styles.page_heading.merge({ text: I18n.t('js.work_packages.tabs.overview') })])
+ end
+ end
+
+ def sums_columns_objects
+ @sums_columns_objects ||= column_objects.select(&:summable?)
+ end
+
+ def sums_table_column_widths
+ widths = sums_columns_objects.map do |col|
+ col.name == :subject || text_column?(col) ? 4.0 : 1.0
+ end
+ widths.unshift 1.0
+ ratio = pdf.bounds.width / widths.sum
+ widths.map { |w| w * ratio }
+ end
+
+ def write_sums_table!(work_packages)
+ rows = [build_sums_header_row]
+ if query.grouped?
+ groups = work_packages.group_by do |work_package|
+ query.group_by_column.value(work_package)
+ end
+ groups.each_key do |group|
+ rows.push build_sums_group_row(group)
+ end
+ end
+ rows.push build_sums_total_row
+ pdf_table_auto_widths(rows, sums_table_column_widths, sums_table_options)
+ end
+
+ def sums_table_options
+ { header: true, cell_style: styles.overview_table_cell.merge({ inline_format: true }) }
+ end
+
+ def build_sums_header_row
+ header_style = styles.overview_table_header_cell
+ row = sums_columns_objects.map do |col|
+ pdf.make_cell(sums_column_name(col), header_style)
+ end
+ content = query.grouped? ? sums_column_name(query.group_by_column) : ''
+ row.unshift pdf.make_cell(content, header_style)
+ row
+ end
+
+ def sums_column_name(col)
+ (col.caption || '').upcase
+ end
+
+ def build_sums_group_row(group)
+ build_sums_row(get_group_sums(group), make_group_label(group), styles.overview_table_cell)
+ end
+
+ def build_sums_total_row
+ build_sums_row(get_total_sums || {}, I18n.t('js.label_sum'), styles.overview_table_sums_cell)
+ end
+
+ def build_sums_row(sums, label, sums_style)
+ sum_row = sums_columns_objects.map do |col|
+ content = get_formatted_value(sums[col], col.name)
+ pdf.make_cell(content, sums_style)
+ end
+ sum_row.unshift pdf.make_cell(label, sums_style)
+ sum_row
+ end
+end
diff --git a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
index 78a0b435934..7bea458e13f 100644
--- a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
+++ b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
@@ -43,6 +43,7 @@ class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exports::Query
include WorkPackage::PDFExport::Common
include WorkPackage::PDFExport::Attachments
include WorkPackage::PDFExport::OverviewTable
+ include WorkPackage::PDFExport::SumsTable
include WorkPackage::PDFExport::WorkPackageDetail
include WorkPackage::PDFExport::TableOfContents
include WorkPackage::PDFExport::Page
@@ -102,6 +103,7 @@ class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exports::Query
write_title!
write_work_packages_toc! work_packages, @id_wp_meta_map if with_descriptions?
write_work_packages_overview! work_packages, @id_wp_meta_map unless with_descriptions?
+ write_work_packages_sums! work_packages if with_sums_table? && with_descriptions?
if should_be_batched?(work_packages)
render_batched(work_packages, filename)
else
diff --git a/config/initializers/export_formats.rb b/config/initializers/export_formats.rb
index d57a36f94ab..eb7447a1a39 100644
--- a/config/initializers/export_formats.rb
+++ b/config/initializers/export_formats.rb
@@ -6,8 +6,11 @@ OpenProject::Application.configure do |application|
single WorkPackage, WorkPackage::PDFExport::WorkPackageToPdf
- formatter WorkPackage, WorkPackage::Exports::Formatters::Costs
formatter WorkPackage, WorkPackage::Exports::Formatters::EstimatedHours
+ formatter WorkPackage, WorkPackage::Exports::Formatters::Hours
+ formatter WorkPackage, WorkPackage::Exports::Formatters::Days
+ formatter WorkPackage, WorkPackage::Exports::Formatters::Currency
+ formatter WorkPackage, WorkPackage::Exports::Formatters::Costs
formatter WorkPackage, Exports::Formatters::CustomField
list Project, Projects::Exports::CSV
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 51ba555f916..859f5630fc6 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1409,6 +1409,9 @@ en:
pdf_report: "PDF Report"
image:
omitted: "Image not exported."
+ units:
+ hours: h
+ days: d
extraction:
available:
diff --git a/modules/bim/lib/open_project/bim/work_package/exporter/formatters/bcf_thumbnail.rb b/modules/bim/lib/open_project/bim/work_package/exporter/formatters/bcf_thumbnail.rb
index 7d903137d35..704c0530263 100644
--- a/modules/bim/lib/open_project/bim/work_package/exporter/formatters/bcf_thumbnail.rb
+++ b/modules/bim/lib/open_project/bim/work_package/exporter/formatters/bcf_thumbnail.rb
@@ -1,6 +1,6 @@
module OpenProject::Bim::WorkPackage::Exporter::Formatters
class BcfThumbnail < ::Exports::Formatters::Default
- def self.apply?(name)
+ def self.apply?(name, _export_format)
name.to_sym == :bcf_thumbnail
end
diff --git a/modules/xls_export/app/models/xls_export/concerns/spreadsheet_builder.rb b/modules/xls_export/app/models/xls_export/concerns/spreadsheet_builder.rb
index 510be58a1e0..10db849c3e4 100644
--- a/modules/xls_export/app/models/xls_export/concerns/spreadsheet_builder.rb
+++ b/modules/xls_export/app/models/xls_export/concerns/spreadsheet_builder.rb
@@ -55,13 +55,13 @@ module XlsExport
def column_values(object)
columns.collect do |column|
- format_attribute(object, column[:name])
+ format_attribute(object, column[:name], :csv)
end
end
def set_column_format_options!(spreadsheet)
columns.each_with_index do |column, i|
- options = formatter_for(column[:name])
+ options = formatter_for(column[:name], :csv)
.format_options
spreadsheet.add_format_option_to_column i, options
diff --git a/spec/models/work_package/exporter/csv_integration_spec.rb b/spec/models/work_package/exporter/csv_integration_spec.rb
index ee9df2f0126..f3f6f49c8ce 100644
--- a/spec/models/work_package/exporter/csv_integration_spec.rb
+++ b/spec/models/work_package/exporter/csv_integration_spec.rb
@@ -76,6 +76,6 @@ RSpec.describe WorkPackage::Exports::CSV, 'integration' do
expect(data.last).to include(work_package.description)
expect(data.last).to include(current_user.name)
expect(data.last).to include(work_package.updated_at.localtime.strftime("%m/%d/%Y %I:%M %p"))
- expect(data.last).to include('(15.0)')
+ expect(data.last).to include('(15.0 h)')
end
end