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

check if meeting agenda item duration exceeds meeting duration, specs missing

Jonas Jabari415d6e8fdbdd
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
index 970f002d119..a61a9304e1d 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
@@ -38,7 +38,7 @@
end
if @meeting_agenda_item.duration_in_minutes.present? && @meeting_agenda_item.duration_in_minutes > 0
- grid.with_area(:duration, Primer::Beta::Text, color: :subtle, mr: 1) do
+ grid.with_area(:duration, Primer::Beta::Text, color: duration_color_scheme, mr: 1) do
I18n.t('datetime.distance_in_words.x_min_abbreviated', count: @meeting_agenda_item.duration_in_minutes)
end
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
index d60ad5b5922..5b637393a3a 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -87,5 +87,13 @@ module MeetingAgendaItems
item.with_leading_visual_icon(icon:)
end
end
+
+ def duration_color_scheme
+ if @meeting.end_time < @meeting_agenda_item.end_time
+ :danger
+ else
+ :subtle
+ end
+ end
end
end
diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.rb b/modules/meeting/app/components/meetings/sidebar/details_component.rb
index 04ac1143f91..a617b913a64 100644
--- a/modules/meeting/app/components/meetings/sidebar/details_component.rb
+++ b/modules/meeting/app/components/meetings/sidebar/details_component.rb
@@ -124,14 +124,23 @@ module Meetings
duration = Duration.new(seconds: @meeting.duration * 3600)
meeting_attribute_row(:stopwatch) do
- if duration.hours > 0
- render(Primer::Beta::Text.new) do
- "#{duration.hours} h #{duration.minutes} min"
- end
- else
- render(Primer::Beta::Text.new) do
- "#{duration.minutes} min"
+ flex_layout do |flex|
+ flex.with_column do
+ if duration.hours > 0
+ render(Primer::Beta::Text.new) do
+ "#{duration.hours} h #{duration.minutes} min"
+ end
+ else
+ render(Primer::Beta::Text.new) do
+ "#{duration.minutes} min"
+ end
+ end
end
+ flex.with_column(ml: 2) do
+ render(Primer::Beta::Text.new(color: :danger, font_size: :small)) do
+ "+ #{ I18n.t('datetime.distance_in_words.x_min_abbreviated', count: @meeting.duration_exceeded_by_agenda_items_in_minutes.to_i)}"
+ end
+ end if @meeting.duration_exceeded_by_agenda_items?
end
end
end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index ee3200d1489..cb3357844f7 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -68,6 +68,7 @@ class MeetingAgendaItemsController < ApplicationController
# enabel continue editing
update_list_via_turbo_stream(form_hidden: false, form_type: @agenda_item_type)
update_header_component_via_turbo_stream
+ update_sidebar_details_component_via_turbo_stream
elsif call.errors[:base].present?
render_base_error_in_flash_message_via_turbo_stream(call)
else
@@ -105,6 +106,7 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
update_item_via_turbo_stream
update_header_component_via_turbo_stream
+ update_sidebar_details_component_via_turbo_stream
elsif call.errors[:base].present?
render_base_error_in_flash_message_via_turbo_stream(call)
else
@@ -124,6 +126,7 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
update_list_via_turbo_stream
update_header_component_via_turbo_stream
+ update_sidebar_details_component_via_turbo_stream
else
generic_call_failure_response(call)
end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 522e689a917..8a3870a7f77 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -230,16 +230,6 @@ class Meeting < ApplicationRecord
self.original_participants_attributes = attrs
end
- def calculate_agenda_item_time_slots
- current_time = start_time
- agenda_items.order(:position).each do |top|
- start_time = current_time
- current_time += top.duration_in_minutes&.minutes || 0.minutes
- end_time = current_time
- top.update_columns(start_time:, end_time:) # avoid callbacks, infinite loop otherwise
- end
- end
-
protected
# Participants of older meetings
diff --git a/modules/meeting/app/models/structured_meeting.rb b/modules/meeting/app/models/structured_meeting.rb
index ffa8145702e..4cc8d7a4213 100644
--- a/modules/meeting/app/models/structured_meeting.rb
+++ b/modules/meeting/app/models/structured_meeting.rb
@@ -28,4 +28,27 @@
class StructuredMeeting < Meeting
has_many :agenda_items, dependent: :destroy, foreign_key: 'meeting_id', class_name: 'MeetingAgendaItem'
+
+ # triggered by MeetingAgendaItem#after_create/after_destroy/after_save
+ def calculate_agenda_item_time_slots
+ current_time = start_time
+ agenda_items.order(:position).each do |top|
+ start_time = current_time
+ current_time += top.duration_in_minutes&.minutes || 0.minutes
+ end_time = current_time
+ top.update_columns(start_time:, end_time:) # avoid callbacks, infinite loop otherwise
+ end
+ end
+
+ def agenda_items_sum_duration_in_minutes
+ agenda_items.sum(:duration_in_minutes)
+ end
+
+ def duration_exceeded_by_agenda_items?
+ agenda_items_sum_duration_in_minutes > (duration*60 || 0)
+ end
+
+ def duration_exceeded_by_agenda_items_in_minutes
+ agenda_items_sum_duration_in_minutes - (duration*60 || 0)
+ end
end