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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Update the agenda item list dropdown menus after create, delete, drop
Dombi Attilad7cc519bc944
diff --git a/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.tsindex ee85369f044..e3e1c0f1d32 100644--- a/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts@@ -28,6 +28,7 @@* ++*/+import * as Turbo from '@hotwired/turbo';import { Controller } from '@hotwired/stimulus';import { Drake } from 'dragula';import { debugLog } from 'core-app/shared/helpers/debug_output';@@ -71,9 +72,8 @@ export default class extends Controller {if (!response.ok) {debugLog('Failed to sort item');} else {- // Wait for the response, but don't render anything, because the order of items is already- // updated via the drop.- await response.text();+ const text = await response.text();+ Turbo.renderStreamMessage(text);}}diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.html.erbnew file mode 100644index 00000000000..878de3e8622--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.html.erb@@ -0,0 +1,10 @@+<%=+ component_wrapper do+ render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_agenda_item_actions"), scheme: :invisible, test_selector: 'op-meeting-agenda-actions')+ edit_action_item(menu) if @meeting_agenda_item.editable?+ move_actions(menu)+ delete_action_item(menu)+ end if edit_enabled?+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.rbnew file mode 100644index 00000000000..e3cb3918224--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/menu_component.rb@@ -0,0 +1,91 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module MeetingAgendaItems+ class ItemComponent::MenuComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting_agenda_item:)+ super++ @meeting_agenda_item = meeting_agenda_item+ @meeting = meeting_agenda_item.meeting+ end++ def wrapper_uniq_by+ @meeting_agenda_item.id+ end++ private++ def edit_enabled?+ @meeting.open? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)+ end++ def edit_action_item(menu)+ menu.with_item(label: t("label_edit"),+ href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),+ content_arguments: {+ data: { 'turbo-stream': true }+ }) do |item|+ item.with_leading_visual_icon(icon: :pencil)+ end+ end++ def move_actions(menu)+ move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless @meeting_agenda_item.first?+ move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless @meeting_agenda_item.first?+ move_action_item(menu, :lower, t("label_agenda_item_move_down"), "chevron-down") unless @meeting_agenda_item.last?+ move_action_item(menu, :lowest, t("label_agenda_item_move_to_bottom"), "move-to-bottom") unless @meeting_agenda_item.last?+ end++ def delete_action_item(menu)+ menu.with_item(label: t("text_destroy"),+ scheme: :danger,+ href: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),+ form_arguments: {+ method: :delete, data: { confirm: t("text_are_you_sure"), 'turbo-stream': true }+ }) do |item|+ item.with_leading_visual_icon(icon: :trash)+ end+ end++ def move_action_item(menu, move_to, label_text, icon)+ menu.with_item(label: label_text,+ href: move_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,+ move_to:),+ form_arguments: {+ method: :put, data: { 'turbo-stream': true }+ }) do |item|+ item.with_leading_visual_icon(icon:)+ end+ end+ end+enddiff --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.erbindex 9634f694505..9a63cd8170d 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@@ -65,12 +65,9 @@endgrid.with_area(:actions, tag: :div, justify_self: :end) do- render(Primer::Alpha::ActionMenu.new) do |menu|- menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_agenda_item_actions"), scheme: :invisible, test_selector: 'op-meeting-agenda-actions')- edit_action_item(menu) if @meeting_agenda_item.editable?- move_actions(menu)- delete_action_item(menu)- end if edit_enabled?+ render(+ MeetingAgendaItems::ItemComponent::MenuComponent.new(meeting_agenda_item: @meeting_agenda_item)+ )endgrid.with_area(:notes, tag: :div) dodiff --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.rbindex eae7805f24e..1f65afc02d3 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@@ -45,49 +45,6 @@ module MeetingAgendaItems@meeting.open? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)end- def edit_enabled?- @meeting.open? && User.current.allowed_in_project?(:manage_agendas, @meeting.project)- end-- def edit_action_item(menu)- menu.with_item(label: t("label_edit"),- href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),- content_arguments: {- data: { 'turbo-stream': true }- }) do |item|- item.with_leading_visual_icon(icon: :pencil)- end- end-- def move_actions(menu)- move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless @meeting_agenda_item.first?- move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless @meeting_agenda_item.first?- move_action_item(menu, :lower, t("label_agenda_item_move_down"), "chevron-down") unless @meeting_agenda_item.last?- move_action_item(menu, :lowest, t("label_agenda_item_move_to_bottom"), "move-to-bottom") unless @meeting_agenda_item.last?- end-- def delete_action_item(menu)- menu.with_item(label: t("text_destroy"),- scheme: :danger,- href: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),- form_arguments: {- method: :delete, data: { confirm: t("text_are_you_sure"), 'turbo-stream': true }- }) do |item|- item.with_leading_visual_icon(icon: :trash)- end- end-- def move_action_item(menu, move_to, label_text, icon)- menu.with_item(label: label_text,- href: move_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,- move_to:),- form_arguments: {- method: :put, data: { 'turbo-stream': true }- }) do |item|- item.with_leading_visual_icon(icon:)- end- end-def duration_color_schemeif @meeting.end_time < @meeting_agenda_item.end_time:dangerdiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex cdfbbecf69b..2dc103e2cc8 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -88,6 +88,14 @@ module Meetings)end+ def update_list_dropdown_menu_via_turbo_stream(meeting: @meeting)+ meeting.agenda_items.each do |meeting_agenda_item|+ update_via_turbo_stream(+ component: MeetingAgendaItems::ItemComponent::MenuComponent.new(meeting_agenda_item:)+ )+ end+ end+def update_new_component_via_turbo_stream(hidden: false, meeting_agenda_item: nil, meeting: @meeting, type: :simple)update_via_turbo_stream(component: MeetingAgendaItems::NewComponent.new(diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 629cdf5d4b7..c3e67aa9220 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -74,6 +74,7 @@ class MeetingAgendaItemsController < ApplicationControllerif call.success?# enable continue editingadd_item_via_turbo_stream(clear_slate:)+ update_list_dropdown_menu_via_turbo_streamupdate_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_streamelse@@ -129,6 +130,7 @@ class MeetingAgendaItemsController < ApplicationControllerif call.success?remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)+ update_list_dropdown_menu_via_turbo_streamupdate_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_streamelse@@ -144,7 +146,7 @@ class MeetingAgendaItemsController < ApplicationController.call(position: params[:position].to_i)if call.success?- update_item_via_turbo_stream+ update_list_dropdown_menu_via_turbo_streamupdate_header_component_via_turbo_streamelsegeneric_call_failure_response(call)