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

refactor: add description column by adding it to the columns array

Christophe Bliard1d517ec26e78
diff --git a/app/models/work_package/exports/csv.rb b/app/models/work_package/exports/csv.rb
index 03acf053380..d5cb2866bed 100644
--- a/app/models/work_package/exports/csv.rb
+++ b/app/models/work_package/exports/csv.rb
@@ -33,35 +33,26 @@ module WorkPackage::Exports
alias :records :work_packages
+ def get_columns
+ if with_descriptions
+ super + [description_column]
+ else
+ super
+ end
+ end
+
private
def title
query.new_record? ? I18n.t(:label_work_package_plural) : query.name
end
- def csv_headers
- return super unless with_descriptions
-
- super + [WorkPackage.human_attribute_name(:description)]
- end
-
def with_descriptions
ActiveModel::Type::Boolean.new.cast(options[:show_descriptions])
end
- # fetch all row values
- def csv_row(work_package)
- return super unless with_descriptions
-
- super.tap do |row|
- if row.any?
- row << if work_package.description
- work_package.description.squish
- else
- ""
- end
- end
- end
+ def description_column
+ Queries::WorkPackages::Selects::PropertySelect.new(:description)
end
end
end