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

join tab panels into one form

Ivan Kuchin21d980efc5f5
diff --git a/app/components/projects/phase_definitions/form_component.html.erb b/app/components/projects/phase_definitions/form_component.html.erb
index f1cb0ed134f..dc25f1805fc 100644
--- a/app/components/projects/phase_definitions/form_component.html.erb
+++ b/app/components/projects/phase_definitions/form_component.html.erb
@@ -33,49 +33,37 @@ See COPYRIGHT and LICENSE files for more details.
) do |f|
flex_layout do |body|
body.with_row do
- render Primer::Alpha::TabPanels.new(label: "label") do |tab_panel|
- tab_panel.with_tab(selected: selected?(:details), id: "tab-phases--details") do |tab|
- tab.with_text { I18n.t("label_details") }
- tab.with_panel do
- render Projects::PhaseDefinitions::DetailsForm.new(f)
- end
- end
- tab_panel.with_tab(selected: selected?(:phase_gates), id: "tab-phases--phase-gates") do |tab|
- tab.with_text { I18n.t("settings.project_phase_definitions.phase_gates") }
- tab.with_panel do
- flex_layout do |gates_tab|
- gates_tab.with_row(mt: 2) do
- render Projects::PhaseDefinitions::StartGateCheckboxForm.new(f)
- end
- gates_tab.with_row(
- mt: 2,
- classes: model.start_gate.blank? ? "d-none" : "",
- data: {
- target_name: "start_gate",
- "show-when-checked-target": "effect",
- visibility_class: "d-none"
- }
- ) do
- render Projects::PhaseDefinitions::StartGateNameForm.new(f)
- end
- gates_tab.with_row(mt: 2) do
- render Projects::PhaseDefinitions::FinishGateCheckboxForm.new(f)
- end
- gates_tab.with_row(
- mt: 2,
- classes: model.finish_gate.blank? ? "d-none" : "",
- data: {
- target_name: "finish_gate",
- "show-when-checked-target": "effect",
- visibility_class: "d-none"
- }
- ) do
- render Projects::PhaseDefinitions::FinishGateNameForm.new(f)
- end
- end
- end
- end
- end
+ render Projects::PhaseDefinitions::DetailsForm.new(f)
+ end
+
+ body.with_row(mt: 2) do
+ render Projects::PhaseDefinitions::StartGateCheckboxForm.new(f)
+ end
+ body.with_row(
+ mt: 2,
+ classes: model.start_gate.blank? ? "d-none" : "",
+ data: {
+ target_name: "start_gate",
+ "show-when-checked-target": "effect",
+ visibility_class: "d-none"
+ }
+ ) do
+ render Projects::PhaseDefinitions::StartGateNameForm.new(f)
+ end
+
+ body.with_row(mt: 2) do
+ render Projects::PhaseDefinitions::FinishGateCheckboxForm.new(f)
+ end
+ body.with_row(
+ mt: 2,
+ classes: model.finish_gate.blank? ? "d-none" : "",
+ data: {
+ target_name: "finish_gate",
+ "show-when-checked-target": "effect",
+ visibility_class: "d-none"
+ }
+ ) do
+ render Projects::PhaseDefinitions::FinishGateNameForm.new(f)
end
body.with_row(mt: 4) do
diff --git a/app/components/projects/phase_definitions/form_component.rb b/app/components/projects/phase_definitions/form_component.rb
index 269bc4aa4d5..d9a70521219 100644
--- a/app/components/projects/phase_definitions/form_component.rb
+++ b/app/components/projects/phase_definitions/form_component.rb
@@ -31,23 +31,5 @@ module Projects::PhaseDefinitions
class FormComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include OpPrimer::FormHelpers
-
- def selected?(tabname)
- tabname == if no_errors || details_tab_errors.any?
- :details
- else
- :phase_gates
- end
- end
-
- private
-
- def no_errors
- model.errors.empty?
- end
-
- def details_tab_errors
- model.errors.attribute_names & %i[name color]
- end
end
end
diff --git a/spec/features/admin/project_phase_definitions_spec.rb b/spec/features/admin/project_phase_definitions_spec.rb
index 7162357e87f..c4346119b6f 100644
--- a/spec/features/admin/project_phase_definitions_spec.rb
+++ b/spec/features/admin/project_phase_definitions_spec.rb
@@ -114,8 +114,6 @@ RSpec.describe "Projects phase definition settings", :js do
fill_in "Name", with: "Initiating"
definitions_page.select_color("Gold")
- click_on "Phase gates"
-
check "Start phase gate"
fill_in "Start phase gate name", with: "Ready to Initiate"
check "Finish phase gate"