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

Allow passing data arguments to the sort helper

Klaus Zanders936b2b438f91
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index cbbda73fd75..9173baa51aa 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -319,11 +319,12 @@ module SortHelper
default_order = options.delete(:default_order) || "asc"
lang = options.delete(:lang) || nil
param = options.delete(:param) || :sort
+ data = options.delete(:data) || {}
options[:title] = sort_header_title(column, caption, options)
within_sort_header_tag_hierarchy(options, sort_class(column)) do
- sort_link(column, caption, default_order, allowed_params:, param:, lang:, title: options[:title])
+ sort_link(column, caption, default_order, allowed_params:, param:, lang:, title: options[:title], data:)
end
end
diff --git a/spec/helpers/sort_helper_spec.rb b/spec/helpers/sort_helper_spec.rb
index 768f5253ec7..96ec6b1048b 100644
--- a/spec/helpers/sort_helper_spec.rb
+++ b/spec/helpers/sort_helper_spec.rb
@@ -244,5 +244,15 @@ RSpec.describe SortHelper do
end
end
end
+
+ describe "passing data params" do
+ let(:options) { { data: { "turbo-stream": true } } }
+
+ it "includes the passed data parm in the link" do
+ expect(output).to be_html_eql(<<~HTML)
+ <th title="Sort by &quot;Id&quot;"><div class="generic-table--sort-header-outer"><div class="generic-table--sort-header"><span><a title="Sort by &quot;Id&quot;" data-turbo-stream="true" href="/work_packages?sort=sort_criteria_params">Id</a></span></div></div></th>
+ HTML
+ end
+ end
end
end