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
Add components and controller logic
Mir Bhatia9a5a40d91396
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.erbindex 3e454e0d875..5752adbd881 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@@ -84,14 +84,12 @@move_to_backlog_action_item(submenu)end- move_to_section_action_item(submenu)+ move_to_section_action_item(submenu) if in_section?endwith_item_group(submenu) domove_to_next_meeting_action_item(submenu) if move_to_next_meeting_enabled?end-- submenu.with_divider if move_to_different_section_or_meeting_action_added?endenddiff --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 5b5358c191f..9be71d4452f 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@@ -199,10 +199,10 @@ module MeetingAgendaItemsendend- def move_to_section_action_item(menu)+ def move_to_backlog_action_item(menu)return unless editable?- menu.with_item(label: "Move to section",+ menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),tag: :button,content_arguments: { data: {action: "click->meetings--add-params#interceptMoveTo",@@ -225,16 +225,18 @@ module MeetingAgendaItemsendend- def move_to_backlog_action_item(menu)+ def move_to_section_action_item(menu)return unless editable?- menu.with_item(label: I18n.t(:label_agenda_item_move_to_backlog),- tag: :button,- content_arguments: { data: {- action: "click->meetings--add-params#interceptMoveTo",- href: drop_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, type: :to_backlog)- } }) do |item|- item.with_leading_visual_icon(icon: "discussion-outdated")+ menu.with_item(label: I18n.t(:label_agenda_item_move_to_section),+ href: move_to_section_dialog_meeting_agenda_item_path(+ @meeting_agenda_item.meeting,+ @meeting_agenda_item+ ),+ content_arguments: {+ data: { controller: "async-dialog" }+ }) do |item|+ item.with_leading_visual_icon(icon: "op-move")endend@@ -263,5 +265,9 @@ module MeetingAgendaItemsdef editable?@editable ||= @meeting_agenda_item.editable? && can_manage_agendas?end++ def in_section?+ true+ endendenddiff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.html.erbnew file mode 100644index 00000000000..9b35078b365--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.html.erb@@ -0,0 +1,69 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<%=+ render(+ Primer::Alpha::Dialog.new(+ title: "Move to section",+ id: "move-to-section-dialog"+ )+ ) do |dialog|+ dialog.with_header(variant: :large)+ dialog.with_body do+ render(+ MeetingAgendaItems::MoveToSectionFormComponent.new(+ agenda_item: @agenda_item+ )+ )+ end+ dialog.with_footer do+ component_collection do |buttons|+ buttons.with_component(+ Primer::Beta::Button.new(+ data: {+ "close-dialog-id": "move-to-section-dialog"+ }+ )+ ) do+ t("button_cancel")+ end+ buttons.with_component(+ Primer::Beta::Button.new(+ scheme: :primary,+ form: "move-to-section-form",+ data: { turbo: true },+ type: :submit+ )+ ) do+ t("button_save")+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.rb b/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.rbnew file mode 100644index 00000000000..b5db5e3dd4b--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_section_dialog_component.rb@@ -0,0 +1,47 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 MoveToSectionDialogComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(agenda_item:)+ super++ @agenda_item = agenda_item+ end++ private+++ end+enddiff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.html.erbnew file mode 100644index 00000000000..8a851afdd74--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.html.erb@@ -0,0 +1,53 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<%=+ component_wrapper do+ primer_form_with(+ id: "move-to-section-form",+ model: @agenda_item,+ method: :post,+ url: move_to_section_meeting_agenda_item_path(+ @agenda_item.meeting,+ @agenda_item+ )+ ) do |f|+ flex_layout(mb: 3) do |flex|+ flex.with_row do+ if @base_errors&.any?+ render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { @base_errors.join("\n") }+ end+ end+ flex.with_row(mb: 3) do+ render(Meeting::AddToSection.new(f, wrapper_id: "move-to-section-dialog"))+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.rb b/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.rbnew file mode 100644index 00000000000..5675e128194--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/move_to_section_form_component.rb@@ -0,0 +1,43 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 MoveToSectionFormComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(agenda_item:)+ super++ @agenda_item = agenda_item+ end+ end+enddiff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 2f8ceb7edb5..135c1feffe7 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -249,6 +249,39 @@ class MeetingAgendaItemsController < ApplicationControllerendend+ def move_to_section_dialog+ respond_with_dialog MeetingAgendaItems::MoveToSectionDialogComponent.new(+ agenda_item: @meeting_agenda_item+ )+ end++ def move_to_section+ meeting_agenda_item_section = @meeting_agenda_item.meeting_section+ meeting_section = MeetingSection.find_by(id: params[:meeting_agenda_item][:meeting_section_id])++ call = ::MeetingAgendaItems::UpdateService+ .new(user: current_user, model: @meeting_agenda_item)+ .call(meeting_section:)++ if call.success?+ old_section, current_section, section_changed = assign_drop_results(call, meeting_agenda_item_section)++ if section_changed+ move_item_to_other_section_via_turbo_stream(+ old_section:,+ current_section:,+ collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed])+ )+ else+ move_item_within_section_via_turbo_stream+ end+ else+ generic_call_failure_response(call)+ end++ respond_with_turbo_streams+ end+privatedef init_next_meeting_occurrencediff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex cf8228c9bf4..26a9bd869b6 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -541,6 +541,7 @@ en:label_agenda_item_move_to_next: "Move to next meeting"label_agenda_item_move_to_backlog: "Move to backlog"label_agenda_item_move_to_current_meeting: "Move to current meeting"+ label_agenda_item_move_to_section: "Move to section"label_agenda_item_move_to_top: "Move to top"label_agenda_item_move_to_bottom: "Move to bottom"label_agenda_item_move_up: "Move up"diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rbindex 986ba535d40..73d7dedd2b6 100644--- a/modules/meeting/config/routes.rb+++ b/modules/meeting/config/routes.rb@@ -113,6 +113,8 @@ Rails.application.routes.draw doput :moveget :move_to_next_dialog, action: :move_to_next_meeting_dialogpost :move_to_next, action: :move_to_next_meeting+ get :move_to_section_dialog+ post :move_to_sectionendendresources :sections, controller: "meeting_sections" dodiff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rbindex f006219388b..a78da3b3bde 100644--- a/modules/meeting/lib/open_project/meeting/engine.rb+++ b/modules/meeting/lib/open_project/meeting/engine.rb@@ -90,7 +90,8 @@ module OpenProject::Meeting{meetings: %i[change_state],meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move- move_to_next_meeting move_to_next_meeting_dialog],+ move_to_next_meeting move_to_next_meeting_dialog+ move_to_section move_to_section_dialog],meeting_sections: %i[new cancel_new create edit cancel_edit update destroy drop moveclear_backlog clear_backlog_dialog]},