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
fix(export): pdf uses Yes/No for boolean custom fields; XLS & CVS do not
as-op9b958f8ce3f9
diff --git a/app/models/exports/formatters/custom_field.rb b/app/models/exports/formatters/custom_field.rbindex 045b197bb9f..66dac9606b1 100644--- a/app/models/exports/formatters/custom_field.rb+++ b/app/models/exports/formatters/custom_field.rb@@ -1,8 +1,8 @@module Exportsmodule Formattersclass CustomField < Default- def self.apply?(attribute, _export_format)- attribute.start_with?("cf_")+ def self.apply?(attribute, export_format)+ export_format != :pdf && attribute.start_with?("cf_")end##@@ -24,7 +24,7 @@ module Exportscase custom_field.field_formatwhen "bool"value = object.typed_custom_value_for(custom_field)- value ? I18n.t(:general_text_Yes) : I18n.t(:general_text_No)+ value == nil ? false : valuewhen "text"object.typed_custom_value_for(custom_field)elsediff --git a/app/models/exports/formatters/custom_field_pdf.rb b/app/models/exports/formatters/custom_field_pdf.rbnew file mode 100644index 00000000000..a299f785a16--- /dev/null+++ b/app/models/exports/formatters/custom_field_pdf.rb@@ -0,0 +1,27 @@+module Exports+ module Formatters+ class CustomFieldPdf < CustomField+ def self.apply?(attribute, export_format)+ export_format == :pdf && attribute.start_with?("cf_")+ end++ ##+ # Print the value meant for export.+ #+ # - For boolean values, use the Yes/No formatting for the PDF+ # treat nil as false+ # - For long text values, output the plain value+ def format_for_export(object, custom_field)+ case custom_field.field_format+ when "bool"+ value = object.typed_custom_value_for(custom_field)+ value ? I18n.t(:general_text_Yes) : I18n.t(:general_text_No)+ when "text"+ object.typed_custom_value_for(custom_field)+ else+ object.formatted_custom_value_for(custom_field)+ end+ end+ end+ end+enddiff --git a/config/initializers/export_formats.rb b/config/initializers/export_formats.rbindex 26f2092b412..3b959de7863 100644--- a/config/initializers/export_formats.rb+++ b/config/initializers/export_formats.rb@@ -15,6 +15,7 @@ Rails.application.configure do |application|formatter WorkPackage, WorkPackage::Exports::Formatters::Costsformatter WorkPackage, WorkPackage::Exports::Formatters::DoneRatioformatter WorkPackage, Exports::Formatters::CustomField+ formatter WorkPackage, Exports::Formatters::CustomFieldPdflist Project, Projects::Exports::CSVformatter Project, Exports::Formatters::CustomField