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
account for the newly build element already being part of the childrens scope
ulferts505dc2b71bf8
diff --git a/app/components/admin/custom_fields/hierarchy/items_component.rb b/app/components/admin/custom_fields/hierarchy/items_component.rbindex 9c83089684a..89253771c21 100644--- a/app/components/admin/custom_fields/hierarchy/items_component.rb+++ b/app/components/admin/custom_fields/hierarchy/items_component.rb@@ -54,13 +54,9 @@ module Adminlist = model.childrenreturn list unless @new_item- position = @new_item.sort_order&.to_i-- if position- list[0...position] + [@new_item] + list[position..]- else- list + [@new_item]- end+ # Sort by sort order. But if there is a new item, sort it to be before the other+ # item that has the same sort order.+ list.sort { |a, b| [a.sort_order.to_i, a.id.to_i] <=> [b.sort_order.to_i, b.id.to_i] }enddef item_headerdiff --git a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb b/app/controllers/admin/custom_fields/hierarchy/items_controller.rbindex ae67c1e363b..a23eda79907 100644--- a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb+++ b/app/controllers/admin/custom_fields/hierarchy/items_controller.rb@@ -56,7 +56,7 @@ module Adminenddef new- @new_item = ::CustomField::Hierarchy::Item.new(parent: @active_item, sort_order: params[:position])+ @new_item = @active_item.children.build(sort_order: params[:position])enddef edit; end