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

Fix logic for determining whether the warning should be displayed

Aaron Contrerasc247323345cd
diff --git a/app/controllers/work_packages/moves_controller.rb b/app/controllers/work_packages/moves_controller.rb
index 4b49e75895b..13d21f49c47 100644
--- a/app/controllers/work_packages/moves_controller.rb
+++ b/app/controllers/work_packages/moves_controller.rb
@@ -117,12 +117,26 @@ class WorkPackages::MovesController < ApplicationController
@target_project ||= @project
@types = @target_project.types.order(:position)
@target_type = @types.find { |t| t.id.to_s == params[:new_type_id].to_s }
- @unavailable_type_in_target_project = @types.exclude?(@target_type)
+ @unavailable_type_in_target_project = set_unavailable_type_in_target_project
@available_versions = @target_project.assignable_versions
@available_statuses = Workflow.available_statuses(@project)
@notes = params[:notes] || ""
end
+ def set_unavailable_type_in_target_project
+ if @target_project == @project
+ false
+ elsif @target_type.nil?
+ Type.where(id: @work_packages.select(:type_id))
+ .select("distinct id")
+ .pluck(:id)
+ .difference(@types.pluck(:id))
+ .any?
+ else
+ @types.exclude?(@target_type)
+ end
+ end
+
def attributes_for_create
permitted_params
.move_work_package