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

fixed agenda item time slot calculation with sections

Jonas Jabari8320a1188bf2
diff --git a/modules/meeting/app/models/meeting_section.rb b/modules/meeting/app/models/meeting_section.rb
index 1f038cc904c..df782a9068d 100644
--- a/modules/meeting/app/models/meeting_section.rb
+++ b/modules/meeting/app/models/meeting_section.rb
@@ -38,10 +38,18 @@ class MeetingSection < ApplicationRecord
before_validation :set_default_title
+ after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |section|
+ section.position_previously_changed?
+ }
+
acts_as_list scope: :meeting
default_scope { order(:position) }
+ def trigger_meeting_agenda_item_time_slots_calculation
+ meeting.calculate_agenda_item_time_slots
+ end
+
def set_default_title
if title.blank?
self.title = I18n.t("meeting_section.untitled_title")
diff --git a/modules/meeting/app/models/structured_meeting.rb b/modules/meeting/app/models/structured_meeting.rb
index c4d42d46979..b4ae24ecfc9 100644
--- a/modules/meeting/app/models/structured_meeting.rb
+++ b/modules/meeting/app/models/structured_meeting.rb
@@ -38,7 +38,7 @@ class StructuredMeeting < Meeting
def calculate_agenda_item_time_slots
current_time = start_time
MeetingAgendaItem.transaction do
- changed_items = agenda_items.order(:position).map do |top|
+ changed_items = agenda_items.includes(:meeting_section).order("meeting_sections.position", :position).map do |top|
start_time = current_time
current_time += top.duration_in_minutes&.minutes || 0.minutes
end_time = current_time