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

added section duration sum

Jonas Jabari7207af30ae36
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 4b54d09ed9c..e81f7b9a857 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
@@ -45,7 +45,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: duration_color_scheme, mr: 1) do
+ grid.with_area(:duration, Primer::Beta::Text, color: duration_color_scheme, mr: 1, font_size: :small) do
I18n.t('datetime.distance_in_words.x_minutes_abbreviated', count: @meeting_agenda_item.duration_in_minutes)
end
end
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 497285cbc93..85898cad564 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
@@ -2,7 +2,7 @@
component_wrapper(data: wrapper_data_attributes) do
# The borderBox needs to be `position: relative` because of bug #49853
# (The action menu items float somewhere on the page as soon as you have to scroll the Box in Firefox)
- flex_layout do |flex|
+ flex_layout(mb: 3) do |flex|
flex.with_row(classes: 'dragula-container', data: { 'allowed-drop-type': 'section' }.merge(drop_target_config) ) do
first_and_last = [@meeting.sections.first, @meeting.sections.last]
render(
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
index 5743a10edaa..496bdd629fe 100644
--- a/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.html.erb
@@ -1,5 +1,5 @@
<%=
- component_wrapper(class: "mt-3", style: "position: relative") do
+ component_wrapper(style: "position: relative") do
render(Primer::Alpha::ActionMenu.new) do |component|
component.with_show_button(scheme: button_scheme, disabled: @disabled) do |button|
button.with_leading_visual_icon(icon: :plus)
diff --git a/modules/meeting/app/components/meeting_sections/header_component.html.erb b/modules/meeting/app/components/meeting_sections/header_component.html.erb
index 6bc8d02bfaa..cd964d5e27c 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb
@@ -13,6 +13,13 @@
@meeting_section.name
end
end
+ if @meeting_section.agenda_items_sum_duration_in_minutes > 0
+ content_container.with_column(ml: 2) do
+ render(Primer::Beta::Text.new(font_size: :small, font_weight: :normal, color: :subtle)) do
+ render(OpenProject::Common::DurationComponent.new(@meeting_section.agenda_items_sum_duration_in_minutes, :minutes, abbreviated: true))
+ end
+ end
+ end
end
if editable?
section_header_container.with_column(flex_layout: true, justify_content: :flex_end) do |actions_container|
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rb
index d625d060f34..e3014290cf3 100644
--- a/modules/meeting/app/components/meeting_sections/show_component.rb
+++ b/modules/meeting/app/components/meeting_sections/show_component.rb
@@ -51,6 +51,10 @@ module MeetingSections
@meeting_section.id
end
+ def editable?
+ @meeting_section.editable? && User.current.allowed_in_project?(:manage_agendas, @meeting_section.project)
+ end
+
def hide_section?
@meeting.sections.count == 1 && @meeting_agenda_items.empty?
end
@@ -60,7 +64,7 @@ module MeetingSections
end
def render_new_button_in_section?
- @meeting_agenda_items.empty? && @form_hidden
+ @meeting_agenda_items.empty? && @form_hidden && editable?
end
def top_margin
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 4a89739eeec..c93a6601a94 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -122,6 +122,7 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
update_item_via_turbo_stream
+ update_section_header_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)
update_header_component_via_turbo_stream
update_sidebar_details_component_via_turbo_stream
else
@@ -134,6 +135,8 @@ class MeetingAgendaItemsController < ApplicationController
end
def destroy
+ section = @meeting_agenda_item.meeting_section
+
call = ::MeetingAgendaItems::DeleteService
.new(user: current_user, model: @meeting_agenda_item)
.call
@@ -141,6 +144,7 @@ class MeetingAgendaItemsController < ApplicationController
if call.success?
remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)
update_header_component_via_turbo_stream
+ update_section_header_via_turbo_stream(meeting_section: section) if section&.reload.present?
update_sidebar_details_component_via_turbo_stream
else
generic_call_failure_response(call)
diff --git a/modules/meeting/app/models/meeting_section.rb b/modules/meeting/app/models/meeting_section.rb
index e3b547fe5a3..29194fe83a4 100644
--- a/modules/meeting/app/models/meeting_section.rb
+++ b/modules/meeting/app/models/meeting_section.rb
@@ -59,4 +59,8 @@ class MeetingSection < ApplicationRecord
def modifiable?
!meeting&.closed?
end
+
+ def agenda_items_sum_duration_in_minutes
+ agenda_items.sum(:duration_in_minutes)
+ end
end