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

more specific UI update when creating sections

Jonas Jabari66c8e0b13111
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
index b38a01d134d..a11caa657be 100644
--- a/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.html.erb
@@ -1,7 +1,7 @@
<%=
component_wrapper(data: wrapper_data_attributes) do
flex_layout(mb: 3) do |flex|
- flex.with_row(classes: 'dragula-container', data: { 'allowed-drop-type': 'section' }.merge(drop_target_config) ) do
+ flex.with_row(classes: 'dragula-container', id: insert_target_modifier_id, data: { 'allowed-drop-type': 'section' }.merge(drop_target_config) ) do
first_and_last = [@meeting.sections.first, @meeting.sections.last]
render(
MeetingSections::ShowComponent.with_collection(
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.rb b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
index 1a6ded0c0f7..8b105616fe3 100644
--- a/modules/meeting/app/components/meeting_agenda_items/list_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
@@ -55,5 +55,13 @@ module MeetingAgendaItems
"target-allowed-drag-type": "section" # the type of dragged items which are allowed to be dropped in this target
}
end
+
+ def insert_target_modified?
+ true
+ end
+
+ def insert_target_modifier_id
+ "meeting-section-new-item"
+ end
end
end
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
index a58e21af65f..2aa79889ad4 100644
--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -301,6 +301,24 @@ module Meetings
)
end
+ def add_section_via_turbo_stream(meeting_section: @meeting_section)
+ if meeting_section.meeting.sections.count <= 2
+ # hide blank slate again through rerendering the list component -> count == 0
+ # or show section wrapper of first untitled section -> count == 1
+ update_list_via_turbo_stream
+ # CODE MAINTENANCE: potentially loosing edit state in last section
+ else
+ append_via_turbo_stream(
+ component: MeetingSections::ShowComponent.new(
+ meeting_section:
+ ),
+ target_component: MeetingAgendaItems::ListComponent.new(
+ meeting: meeting_section.meeting
+ )
+ )
+ end
+ end
+
def remove_section_via_turbo_stream(meeting_section: @meeting_section)
if meeting_section.meeting.sections.count <= 1
# show blank slate again through rerendering the list component -> count == 0
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index d20991821a2..641e7571b7c 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -50,7 +50,7 @@ class MeetingSectionsController < ApplicationController
@meeting_section = call.result
if call.success?
- update_all_via_turbo_stream # TODO: more specific UI update
+ add_section_via_turbo_stream
update_section_header_via_turbo_stream(state: :edit)
update_new_button_via_turbo_stream(disabled: true)
else
@@ -109,6 +109,9 @@ class MeetingSectionsController < ApplicationController
if call.success?
remove_section_via_turbo_stream
+ # in case the destroy action was called from the cancel_edit action
+ # we need to update the new button state, which was disabled before
+ update_new_button_via_turbo_stream(disabled: false)
else
generic_call_failure_response(call)
end