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

[#65082] Fix editing of multiple agenda items

Alexander Brandon Coles57d7c71cbff4
diff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb
index fe405d7c7ed..cb1c919fb23 100644
--- a/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.html.erb
@@ -3,7 +3,8 @@
primer_form_with(
model: @meeting_agenda_item,
method: @method,
- url: @submit_path
+ url: @submit_path,
+ namespace: "form_#{wrapper_uniq_by}"
) do |f|
grid_layout("op-meeting-agenda-item-form", tag: :div) do |grid|
grid.with_area(:title) do
diff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.rb b/modules/meeting/app/components/meeting_agenda_items/form_component.rb
index 351b58387ea..4b525f38b21 100644
--- a/modules/meeting/app/components/meeting_agenda_items/form_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -48,7 +49,7 @@ module MeetingAgendaItems
end
def wrapper_uniq_by
- @meeting_agenda_item.id
+ @meeting_agenda_item.persisted? ? @meeting_agenda_item.id : "new"
end
def render?
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb
index 2222c351bdf..4cb740f4cf5 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb
@@ -3,7 +3,8 @@
primer_form_with(
model: @meeting_outcome,
method: @method,
- url: @submit_path
+ url: @submit_path,
+ namespace: "form_#{wrapper_uniq_by}"
) do |f|
flex_layout(tag: :div) do |flex|
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb
index 5bda0ff70ea..935a42cb34f 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb
@@ -44,7 +44,7 @@ module MeetingAgendaItems::Outcomes
end
def wrapper_uniq_by
- @meeting_outcome.id
+ @meeting_outcome.persisted? ? @meeting_outcome.id : "new"
end
private
diff --git a/modules/meeting/spec/components/meeting_agenda_items/form_component_spec.rb b/modules/meeting/spec/components/meeting_agenda_items/form_component_spec.rb
index e6265ee79b5..84ae7f6720a 100644
--- a/modules/meeting/spec/components/meeting_agenda_items/form_component_spec.rb
+++ b/modules/meeting/spec/components/meeting_agenda_items/form_component_spec.rb
@@ -50,6 +50,20 @@ RSpec.describe MeetingAgendaItems::FormComponent, type: :component do
)
end
+ context "with a new agenda item" do
+ let(:meeting_agenda_item) { MeetingAgendaItem.new(meeting:, meeting_section:) }
+
+ it "renders component wrapper" do
+ expect(rendered_component).to have_element id: "meeting-agenda-items-form-component-new"
+ end
+ end
+
+ context "with an existing agenda item" do
+ it "renders component wrapper" do
+ expect(rendered_component).to have_element id: "meeting-agenda-items-form-component-#{meeting_agenda_item.id}"
+ end
+ end
+
it "renders form" do
expect(rendered_component).to have_element :form, method:, action: submit_path
end
diff --git a/modules/meeting/spec/components/meeting_agenda_items/outcomes/form_component_spec.rb b/modules/meeting/spec/components/meeting_agenda_items/outcomes/form_component_spec.rb
index 1aeaacf334a..d806f0ad122 100644
--- a/modules/meeting/spec/components/meeting_agenda_items/outcomes/form_component_spec.rb
+++ b/modules/meeting/spec/components/meeting_agenda_items/outcomes/form_component_spec.rb
@@ -50,6 +50,20 @@ RSpec.describe MeetingAgendaItems::Outcomes::FormComponent, type: :component do
)
end
+ context "with a new outcome" do
+ let(:meeting_outcome) { MeetingOutcome.new(meeting_agenda_item:) }
+
+ it "renders component wrapper" do
+ expect(rendered_component).to have_element id: "meeting-agenda-items-outcomes-form-component-new"
+ end
+ end
+
+ context "with an existing outcome" do
+ it "renders component wrapper" do
+ expect(rendered_component).to have_element id: "meeting-agenda-items-outcomes-form-component-#{meeting_outcome.id}"
+ end
+ end
+
it "renders form" do
expect(rendered_component).to have_element :form, method:, action: submit_path
end
diff --git a/modules/meeting/spec/features/meetings_autofocus_spec.rb b/modules/meeting/spec/features/meetings_autofocus_spec.rb
index 900635cb7f6..e0853a085db 100644
--- a/modules/meeting/spec/features/meetings_autofocus_spec.rb
+++ b/modules/meeting/spec/features/meetings_autofocus_spec.rb
@@ -72,7 +72,7 @@ RSpec.describe "Meetings autofocus", :js do
## without sections
# add item
show_page.add_agenda_item do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "My agenda item"
end
@@ -92,7 +92,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit item
show_page.edit_agenda_item(item) do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")
fill_in "Title", with: "Updated title"
click_on "Save"
@@ -101,7 +101,7 @@ RSpec.describe "Meetings autofocus", :js do
# add second item
show_page.add_agenda_item do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "Second"
end
@@ -134,7 +134,7 @@ RSpec.describe "Meetings autofocus", :js do
# add wp item
show_page.add_agenda_item(type: WorkPackage) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_work_package_id")
select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),
query: "task",
@@ -147,7 +147,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit wp item
show_page.edit_agenda_item(wp_item) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")
click_on "Cancel"
end
@@ -185,7 +185,7 @@ RSpec.describe "Meetings autofocus", :js do
## inside a section
# add item
show_page.add_agenda_item do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "My agenda item"
end
@@ -205,7 +205,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit item
show_page.edit_agenda_item(item) do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")
fill_in "Title", with: "Updated title"
click_on "Save"
@@ -214,7 +214,7 @@ RSpec.describe "Meetings autofocus", :js do
# add second item
show_page.add_agenda_item do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "Second"
end
@@ -247,7 +247,7 @@ RSpec.describe "Meetings autofocus", :js do
# add wp item
show_page.add_agenda_item(type: WorkPackage) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_work_package_id")
select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),
query: "task",
@@ -260,7 +260,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit wp item
show_page.edit_agenda_item(wp_item) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")
click_on "Cancel"
end
@@ -279,7 +279,7 @@ RSpec.describe "Meetings autofocus", :js do
# add item
show_page.add_agenda_item_to_backlog do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "My agenda item"
end
@@ -299,7 +299,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit item
show_page.edit_agenda_item(item) do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")
fill_in "Title", with: "Updated title"
click_on "Save"
@@ -308,7 +308,7 @@ RSpec.describe "Meetings autofocus", :js do
# add second item
show_page.add_agenda_item_to_backlog do
- show_page.expect_focused_input("meeting_agenda_item_title")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_title")
fill_in "Title", with: "Second"
end
@@ -317,7 +317,7 @@ RSpec.describe "Meetings autofocus", :js do
# add wp item
show_page.add_agenda_item_to_backlog(type: WorkPackage) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_new_meeting_agenda_item_work_package_id")
select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),
query: "task",
@@ -330,7 +330,7 @@ RSpec.describe "Meetings autofocus", :js do
# edit wp item
show_page.edit_agenda_item(wp_item) do
- show_page.expect_focused_input("meeting_agenda_item_work_package_id")
+ show_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")
click_on "Cancel"
end
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 5f02b28625e..420eef5d830 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -153,7 +153,7 @@ module Pages::Meetings
end
def in_agenda_form(&)
- page.within("#meeting-agenda-items-form-component", &)
+ page.within("#meeting-agenda-items-form-component-new", &)
end
def assert_agenda_order!(*titles)