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
[#52147] reorganize quick action table header methods
Tobias Dillmann39322117e20f
diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erbindex 26fc30b15c2..5e16a55c21d 100644--- a/app/components/projects/table_component.html.erb+++ b/app/components/projects/table_component.html.erb@@ -55,7 +55,7 @@ See COPYRIGHT and LICENSE files for more details.</div></th><% elsif sortable_column?(column) %>- <%= build_new_sort_header column.attribute, order_options(column, turbo: true) %>+ <%= build_sort_header column.attribute, order_options(column, turbo: true) %><% elsif column.attribute == :favored %><th><div class="generic-table--header-outer">diff --git a/app/components/projects/table_component.rb b/app/components/projects/table_component.rbindex 518bf403094..751645cd2fb 100644--- a/app/components/projects/table_component.rb+++ b/app/components/projects/table_component.rb@@ -67,11 +67,6 @@ module Projectshelpers.projects_sort_header_tag(column, **options, param: :json)end- def build_new_sort_header(column, options)- helpers.projects_new_sort_header_tag(column, **options, param: :json)- end--# We don't return the project row# but the [project, level] array from the helperdef rowsdiff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rbindex 053e7d10729..09ce1b37516 100644--- a/app/helpers/projects_helper.rb+++ b/app/helpers/projects_helper.rb@@ -39,16 +39,6 @@ module ProjectsHelper@sort_criteria.criteria.reject! { |a, _| a == "lft" }- sort_header_tag(column, **, allowed_params: projects_query_param_names_for_sort)- ensure- @sort_criteria.criteria = former_criteria- end-- def projects_new_sort_header_tag(column, **)- former_criteria = @sort_criteria.criteria.dup-- @sort_criteria.criteria.reject! { |a, _| a == "lft" }-sort_header_with_action_menu(column, **, allowed_params: projects_query_param_names_for_sort)ensure@sort_criteria.criteria = former_criteriadiff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rbindex e583f0a10ef..6ee1b2f2cab 100644--- a/app/helpers/sort_helper.rb+++ b/app/helpers/sort_helper.rb@@ -314,21 +314,20 @@ module SortHelper# </th>#def sort_header_tag(column, allowed_params: nil, **options)- caption = get_caption(column, options)-- 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], data:)+ with_sort_header_options(column, allowed_params:, **options) do |col, cap, default_ord, **opts|+ sort_link(col, cap, default_ord, **opts)endenddef sort_header_with_action_menu(column, allowed_params: nil, **options)+ with_sort_header_options(column, allowed_params:, **options) do |col, cap, default_ord, **opts|+ action_menu(col, cap, default_ord, **opts)+ end+ end++ # Extracts the given `options` and provides them to a block.+ # See #sort_header_tag and #sort_header_with_action_menu for usage examples.+ def with_sort_header_options(column, allowed_params: nil, **options)caption = get_caption(column, options)default_order = options.delete(:default_order) || "asc"@@ -339,7 +338,7 @@ module SortHelperoptions[:title] = sort_header_title(column, caption, options)within_sort_header_tag_hierarchy(options, sort_class(column)) do- action_menu(column, caption, default_order, allowed_params:, param:, lang:, title: options[:title], data:)+ yield(column, caption, default_order, allowed_params:, param:, lang:, title: options[:title], data:)endend@@ -398,6 +397,9 @@ module SortHelper}.merge(extra_args)end+ # Accepts a column and returns the corresponding filter name.+ # For some columns, there is no such filter. The method returns nil for these cases.+ # TODO: move project specific logic to a project specific file.def filter_conversion(column)col = column.to_s