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

enable ordering work packages by hierarchy items

Bruno Pagno4d71b909cfc9
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rb
index 86984954fee..0e4da57f8f5 100644
--- a/app/models/custom_field/order_statements.rb
+++ b/app/models/custom_field/order_statements.rb
@@ -31,7 +31,7 @@ module CustomField::OrderStatements
# value of the custom field.
def order_statement
case field_format
- when "string", "date", "bool", "link", "int", "float", "list", "user", "version"
+ when "string", "date", "bool", "link", "int", "float", "list", "user", "version", "hierarchy"
"cf_order_#{id}.value"
end
end
@@ -52,6 +52,8 @@ module CustomField::OrderStatements
join_for_order_by_user_sql
when "version"
join_for_order_by_version_sql
+ when "hierarchy"
+ join_for_order_by_hierarchy_sql
end
end
@@ -167,4 +169,9 @@ module CustomField::OrderStatements
multi_value:
)
end
+
+ def join_for_order_by_hierarchy_sql
+ table_name = CustomField::Hierarchy::Item.quoted_table_name
+ join_for_order_sql(value: "item.label", join: "INNER JOIN #{table_name} item ON item.id = cv.value::bigint")
+ end
end