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

[#57388] restore column order from last save

Tobias Dillmanne56d3c975ef4
diff --git a/app/components/work_packages/exports/column_selection_component.rb b/app/components/work_packages/exports/column_selection_component.rb
index 3412854af4f..ea6b2db5582 100644
--- a/app/components/work_packages/exports/column_selection_component.rb
+++ b/app/components/work_packages/exports/column_selection_component.rb
@@ -61,10 +61,11 @@ module WorkPackages
def selected_columns
if export_settings.settings.key?(:columns)
- # FIXME: the order of the columns is not preserved
saved_cols = export_settings.settings[:columns]
- available_columns
- .select { |column| saved_cols.include?(column[:id]) }
+ # Restore the saved columns, retaining the saved order
+ saved_cols.filter_map do |col|
+ available_columns.find { |c| c[:id] == col }
+ end
else
query
.columns
diff --git a/app/components/work_packages/exports/pdf/report/export_settings_component.html.erb b/app/components/work_packages/exports/pdf/report/export_settings_component.html.erb
index 4bd8abc39ae..e56ce7c089e 100644
--- a/app/components/work_packages/exports/pdf/report/export_settings_component.html.erb
+++ b/app/components/work_packages/exports/pdf/report/export_settings_component.html.erb
@@ -31,7 +31,7 @@
<%= render(
Primer::Alpha::CheckBox.new(
name: "show_images",
- checked: export_settings.settings.fetch(:show_images, true).to_bool,
+ checked: export_settings.settings.fetch(:show_images, true).to_s.to_bool,
value: "true",
unchecked_value: "false",
label: I18n.t("export.dialog.pdf.include_images.label"),
diff --git a/app/models/export_setting.rb b/app/models/export_setting.rb
index fb1d9eaf291..1eee4a68dc4 100644
--- a/app/models/export_setting.rb
+++ b/app/models/export_setting.rb
@@ -52,7 +52,7 @@ class ExportSetting < ApplicationRecord
# Some boolean settings are saved as string. Use this method to conveniently check if they are
# set to true. Assumes that all boolean settings default to false.
def true?(key)
- settings.fetch(key, false).to_bool
+ settings.fetch(key, false).to_s.to_bool
end
private