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

[61551] Fix creating children from relations tab in status-based mode

Christophe Bliard2fb3154a01ff
diff --git a/app/forms/work_packages/dialogs/create_form.rb b/app/forms/work_packages/dialogs/create_form.rb
index b696d1a0800..0c5e9fd8cf7 100644
--- a/app/forms/work_packages/dialogs/create_form.rb
+++ b/app/forms/work_packages/dialogs/create_form.rb
@@ -94,7 +94,10 @@ module WorkPackages::Dialogs
render_custom_fields(form: f)
# Keep hidden fields for relevant changes
- work_package.changes.except(:description, :subject, :type_id).each do |attribute, value|
+ work_package.changes
+ .slice(*writable_attributes)
+ .except(:description, :subject, :type_id)
+ .each do |attribute, value|
f.hidden(name: attribute, value:)
end
end
@@ -112,5 +115,10 @@ module WorkPackages::Dialogs
def custom_fields
@custom_fields ||= work_package.available_custom_fields.select(&:required?)
end
+
+ def writable_attributes
+ contract = WorkPackages::CreateContract.new(work_package, User.current)
+ contract.writable_attributes
+ end
end
end
diff --git a/spec/features/work_packages/tabs/relations_children_spec.rb b/spec/features/work_packages/tabs/relations_children_spec.rb
index 9cac8a1cd4c..9794de839a0 100644
--- a/spec/features/work_packages/tabs/relations_children_spec.rb
+++ b/spec/features/work_packages/tabs/relations_children_spec.rb
@@ -118,6 +118,25 @@ RSpec.describe "Relations children tab", :js, :with_cuprite do
relations_tab.expect_no_new_relation_type("New child")
end
end
+
+ context "in status-based progress calculation mode (bug #61551)",
+ with_settings: { work_package_done_ratio: "status" } do
+ it "can add a new child" do
+ wp_page.visit_tab!("relations")
+ relations_tab.select_relation_type "New child"
+
+ create_dialog.select_type "Task"
+ create_dialog.set_subject "Hello there"
+ create_dialog.submit
+
+ wait_for_network_idle
+
+ page.within("#work-package-relations-tab-content") do
+ expect(page).to have_content("Hello there")
+ expect(page).to have_content("TASK")
+ end
+ end
+ end
end
context "without permissions to add children" do