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

add agenda items via section action menu

Jonas Jabari3b2b2a7cee19
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 0509445bdac..4b54d09ed9c 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
@@ -70,7 +70,11 @@
test_selector: 'op-meeting-agenda-actions')
edit_action_item(menu) if @meeting_agenda_item.editable?
add_note_action_item(menu) if @meeting_agenda_item.editable? && @meeting_agenda_item.notes.blank?
- move_actions(menu)
+ unless first? && last?
+ menu.with_divider
+ move_actions(menu)
+ end
+ menu.with_divider
delete_action_item(menu)
end
end
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 be4d99a8c3d..e10091e7286 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/header_component.html.erb
@@ -3,8 +3,10 @@
if @state == :show
flex_layout(justify_content: :space_between, align_items: :center) do |section_header_container|
section_header_container.with_column(flex_layout: true, align_items: :center) do |content_container|
- content_container.with_column(mr: 2) do
- render(Primer::OpenProject::DragHandle.new(classes: 'handle'))
+ content_container.with_column(mr: @meeting_section.editable? ? 2 : 4) do
+ if @meeting_section.editable?
+ render(Primer::OpenProject::DragHandle.new(classes: 'handle'))
+ end
end
content_container.with_column do
render(Primer::Beta::Text.new(font_weight: :bold)) do
@@ -12,16 +14,25 @@
end
end
end
- section_header_container.with_column(flex_layout: true, justify_content: :flex_end) do |actions_container|
- actions_container.with_column do
- render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|
- menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("settings.project_attributes.label_section_actions"), scheme: :invisible)
- edit_action_item(menu)
- move_actions(menu)
- if @meeting_agenda_items.empty?
- delete_action_item(menu)
- else
- disabled_delete_action_item(menu)
+ if @meeting_section.editable?
+ section_header_container.with_column(flex_layout: true, justify_content: :flex_end) do |actions_container|
+ actions_container.with_column do
+ render(Primer::Alpha::ActionMenu.new(data: { test_selector: "meeting-section-action-menu" })) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("settings.project_attributes.label_section_actions"), scheme: :invisible)
+ edit_action_item(menu)
+ unless first? && last?
+ menu.with_divider
+ move_actions(menu)
+ end
+ menu.with_divider
+ add_agenda_item_action(menu)
+ add_work_package_action(menu)
+ menu.with_divider
+ if @meeting_agenda_items.empty?
+ delete_action_item(menu)
+ else
+ disabled_delete_action_item(menu)
+ end
end
end
end
diff --git a/modules/meeting/app/components/meeting_sections/header_component.rb b/modules/meeting/app/components/meeting_sections/header_component.rb
index 7293583a6e2..bfa42774353 100644
--- a/modules/meeting/app/components/meeting_sections/header_component.rb
+++ b/modules/meeting/app/components/meeting_sections/header_component.rb
@@ -56,6 +56,24 @@ module MeetingSections
}
end
+ def first?
+ @first ||=
+ if @first_and_last.first
+ @first_and_last.first == @meeting_section
+ else
+ @meeting_section.first?
+ end
+ end
+
+ def last?
+ @last ||=
+ if @first_and_last.last
+ @first_and_last.last == @meeting_section
+ else
+ @meeting_section.last?
+ end
+ end
+
def move_actions(menu)
unless first?
move_action_item(menu, :highest, t("label_agenda_item_move_to_top"),
@@ -98,6 +116,31 @@ module MeetingSections
end
end
+ def add_agenda_item_action(menu)
+ menu.with_item(
+ label: t("activerecord.models.meeting_agenda_item", count: 1),
+ href: new_meeting_agenda_item_path(@meeting_section.meeting, type: "simple", meeting_section_id: @meeting_section&.id),
+ content_arguments: {
+ data: { "turbo-stream": true, "test-selector": "meeting-section-add-agenda-item-from-menu" }
+ }
+ ) do |item|
+ item.with_leading_visual_icon(icon: :plus)
+ end
+ end
+
+ def add_work_package_action(menu)
+ menu.with_item(
+ label: t("activerecord.models.work_package", count: 1),
+ href: new_meeting_agenda_item_path(@meeting_section.meeting, type: "work_package",
+ meeting_section_id: @meeting_section&.id),
+ content_arguments: {
+ data: { "turbo-stream": true, "test-selector": "meeting-section-add-work-package-from-menu" }
+ }
+ ) do |item|
+ item.with_leading_visual_icon(icon: :plus)
+ end
+ end
+
def delete_action_item(menu)
menu.with_item(label: t("text_destroy"),
scheme: :danger,