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
Selectable fields are inserted
Klaus Zandersfb35c1d6ef07
diff --git a/app/components/projects/configure_view_modal_component.html.erb b/app/components/projects/configure_view_modal_component.html.erbindex 922c6f870db..c87acbeeca1 100644--- a/app/components/projects/configure_view_modal_component.html.erb+++ b/app/components/projects/configure_view_modal_component.html.erb@@ -39,7 +39,7 @@<% tab_panel.with_tab(id: "tab-selects") do |tab| %><% tab.with_text { "Sort By" }%><% tab.with_panel do %>- <%= render(Queries::SortByComponent.new(query: query)) %>+ <%= render(Queries::SortByComponent.new(query: query, selectable_columns:)) %><% end%><% end %><% end %>diff --git a/app/components/projects/configure_view_modal_component.rb b/app/components/projects/configure_view_modal_component.rbindex 2b0d92552cb..8c68d157629 100644--- a/app/components/projects/configure_view_modal_component.rb+++ b/app/components/projects/configure_view_modal_component.rb@@ -35,6 +35,12 @@ class Projects::ConfigureViewModalComponent < ApplicationComponentoptions :query+ def selectable_columns+ @selectable_columns ||= [+ { id: :lft, name: I18n.t(:label_project_hierarchy) }+ ] + helpers.projects_columns_options+ end+def selected_columns@selected_columns ||= query.selectsdiff --git a/app/components/queries/sort_by_component.rb b/app/components/queries/sort_by_component.rbindex 51531cdf18e..f0baaca4b2e 100644--- a/app/components/queries/sort_by_component.rb+++ b/app/components/queries/sort_by_component.rb@@ -30,6 +30,7 @@class Queries::SortByComponent < ApplicationComponentoptions :query+ options :selectable_columnsdef current_ordersJSON.dump(query.orders.map { |order| [order.attribute, order.direction] })@@ -41,11 +42,10 @@ class Queries::SortByComponent < ApplicationComponentdef available_orders@available_orders ||= begin- all_selectable_columns = helpers.projects_columns_optionsall_order_keys = ::Queries::Register.orders[query.class]&.map(&:key)# Keys from the order can be symbols, strings or regexes- all_selectable_columns.select do |column_option|+ selectable_columns.select do |column_option|all_order_keys.any? { |order_key| order_key === column_option[:id] }endend