From 5623f8e495d31b28dbf7be916b6d025b1c286481 Mon Sep 17 00:00:00 2001 From: Bruno Pagno Date: Thu, 28 Nov 2024 17:08:32 +0100 Subject: [PATCH] enable ordering work packages by hierarchy items --- app/models/custom_field/order_statements.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rb index 86984954feea..0e4da57f8f52 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 @@ def order_join_statement 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 @@ def join_for_order_by_version_sql 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