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
Clean up implementation and use with_item_group in submenu
Mir Bhatiabb40ef2b7ae7
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 fa08a8aa01a..5818042deb1 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@@ -75,28 +75,24 @@add_outcome_action_item(menu) if add_outcome_action?end- with_item_group(menu) do- if editable?- menu.with_sub_menu_item(label: "Move") do |submenu|- unless first? && last?- move_actions(submenu)- end+ if editable?+ with_item_group(menu) do+ menu.with_sub_menu_item(label: I18n.t("label_agenda_item_move")) do |submenu|+ submenu.with_leading_visual_icon(icon: :"op-arrow-in")+ with_item_group(submenu) { move_actions(submenu) } unless first? && last?- submenu.with_divider if move_to_different_section_or_meeting_action_added? && !(first? && last?)-- if !in_template? || in_backlog?- if in_backlog?- move_to_current_meeting_action_item(submenu)- else- move_to_backlog_action_item(submenu)+ with_item_group(submenu) do+ if !in_template? || in_backlog?+ if in_backlog?+ move_to_current_meeting_action_item(submenu)+ else+ move_to_backlog_action_item(submenu)+ end+ move_to_section_action_item(submenu)end- move_to_section_action_item(submenu)end- if move_to_next_meeting_enabled?- submenu.with_divider- move_to_next_meeting_action_item(submenu)- end+ with_item_group(submenu) { move_to_next_meeting_action_item(submenu) }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.erbindex a5aae3fa0b8..8fb43504a06 100644--- 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.erb@@ -31,11 +31,12 @@ See COPYRIGHT and LICENSE files for more details.render(Primer::Alpha::Dialog.new(title: "Move to section",- id: "move-to-section-dialog"+ id: "move-to-section-dialog",+ size: :large)) do |dialog|dialog.with_header(variant: :large)- dialog.with_body do+ dialog.with_body(classes: "Overlay-body_autocomplete_height") dorender(MeetingAgendaItems::MoveToSectionFormComponent.new(meeting: @meeting,diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 05fd03b127d..2361d7aa108 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -38,6 +38,8 @@ class MeetingAgendaItemsController < ApplicationControllerbefore_action :set_agenda_item_type, only: %i[new create]before_action :set_meeting_agenda_item,except: %i[new cancel_new create]+ before_action :set_current_occurrence,+ only: %i[new cancel_new edit cancel_edit create update destroy drop move move_to_section_dialog]before_action :authorizebefore_action :check_recurring_meeting_param, only: %i[move_to_next_meeting]before_action :assign_drop_params, only: %i[drop]@@ -53,33 +55,49 @@ class MeetingAgendaItemsController < ApplicationControllercollapsed = falseendend- current_occurrence = Meeting.find_by(id: params[:current_occurrence])- render_agenda_item_form_via_turbo_stream(meeting_section:, collapsed:, type: @agenda_item_type, current_occurrence:)+ render_agenda_item_form_via_turbo_stream(meeting_section:, collapsed:, type: @agenda_item_type,+ current_occurrence: @current_occurrence)endrespond_with_turbo_streamsenddef cancel_new- current_occurrence = Meeting.find_by(id: params[:current_occurrence])if params[:meeting_section_id].present?meeting_section = MeetingSection.find_by(id: params[:meeting_section_id])if meeting_section.agenda_items.empty?if meeting_section.backlog?collapsed = falseend- update_section_via_turbo_stream(form_hidden: true, meeting_section:, collapsed:, current_occurrence:)+ update_section_via_turbo_stream(form_hidden: true, meeting_section:, collapsed:, current_occurrence: @current_occurrence)endend- update_new_component_via_turbo_stream(hidden: true, meeting_section:, current_occurrence:)+ update_new_component_via_turbo_stream(hidden: true, meeting_section:, current_occurrence: @current_occurrence)update_new_button_via_turbo_stream(disabled: false) unless meeting_section&.backlog?respond_with_turbo_streamsend+ def edit+ if @meeting_agenda_item.editable?+ update_item_via_turbo_stream(state: :edit, display_notes_input: params[:display_notes_input],+ current_occurrence: @current_occurrence)+ else+ update_all_via_turbo_stream+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))+ end++ respond_with_turbo_streams+ end++ def cancel_edit+ update_item_via_turbo_stream(state: :show, current_occurrence: @current_occurrence)++ respond_with_turbo_streams+ end+def create # rubocop:disable Metrics/AbcSize- current_occurrence = Meeting.find_by(id: params[:current_occurrence])call = ::MeetingAgendaItems::CreateService.new(user: current_user).call(@@ -94,18 +112,18 @@ class MeetingAgendaItemsController < ApplicationControllerif call.success?if @meeting_agenda_item.meeting_section.backlog?update_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section, collapsed: false,- current_occurrence:)+ current_occurrence: @current_occurrence)elsereset_meeting_from_agenda_item# enable continue editingupdate_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_stream- add_item_via_turbo_stream(clear_slate: false, current_occurrence:)+ add_item_via_turbo_stream(clear_slate: false, current_occurrence: @current_occurrence)endelse# show errorsupdate_new_component_via_turbo_stream(- hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type, current_occurrence:+ hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type, current_occurrence: @current_occurrence)render_base_error_in_flash_message_via_turbo_stream(call.errors)end@@ -113,27 +131,7 @@ class MeetingAgendaItemsController < ApplicationControllerrespond_with_turbo_streamsend- def edit- current_occurrence = Meeting.find_by(id: params[:current_occurrence])- if @meeting_agenda_item.editable?- update_item_via_turbo_stream(state: :edit, display_notes_input: params[:display_notes_input], current_occurrence:)- else- update_all_via_turbo_stream- render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))- end-- respond_with_turbo_streams- end-- def cancel_edit- current_occurrence = Meeting.find_by(id: params[:current_occurrence])- update_item_via_turbo_stream(state: :show, current_occurrence:)-- respond_with_turbo_streams- end-def update # rubocop:disable Metrics/AbcSize- current_occurrence = Meeting.find_by(id: params[:current_occurrence])call = ::MeetingAgendaItems::UpdateService.new(user: current_user, model: @meeting_agenda_item).call(meeting_agenda_item_params)@@ -144,11 +142,11 @@ class MeetingAgendaItemsController < ApplicationControllerupdate_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_streamend- update_item_via_turbo_stream(current_occurrence:)+ update_item_via_turbo_stream(current_occurrence: @current_occurrence)update_section_header_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)else# show errors- update_item_via_turbo_stream(state: :edit, current_occurrence:)+ update_item_via_turbo_stream(state: :edit, current_occurrence: @current_occurrence)render_base_error_in_flash_message_via_turbo_stream(call.errors)end@@ -156,7 +154,6 @@ class MeetingAgendaItemsController < ApplicationControllerenddef destroy # rubocop:disable Metrics/AbcSize- current_occurrence = Meeting.find_by(id: params[:current_occurrence])section = @meeting_agenda_item.meeting_sectioncall = ::MeetingAgendaItems::DeleteService@@ -165,12 +162,12 @@ class MeetingAgendaItemsController < ApplicationControllerif call.success?if section.backlog?- update_section_via_turbo_stream(meeting_section: section, collapsed: false, current_occurrence:)+ update_section_via_turbo_stream(meeting_section: section, collapsed: false, current_occurrence: @current_occurrence)elsereset_meeting_from_agenda_itemupdate_header_component_via_turbo_streamupdate_sidebar_details_component_via_turbo_stream- remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?, current_occurrence:)+ remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?, current_occurrence: @current_occurrence)# If section is deleted via an after_destroy/after_update action, it needs to be handled separatelyif MeetingSection.exists?(section.id) && section&.reload.present?@@ -185,30 +182,28 @@ class MeetingAgendaItemsController < ApplicationControllerenddef drop- current_occurrence = Meeting.find_by(id: params[:current_occurrence])meeting_agenda_item_section = @meeting_agenda_item.meeting_sectioncall = if @target_id.nil?::MeetingAgendaItems::UpdateService.new(user: current_user, model: @meeting_agenda_item)- .call(meeting: current_occurrence, meeting_section: nil)+ .call(meeting: @current_occurrence, meeting_section: nil)else::MeetingAgendaItems::DropService.new(user: current_user, meeting_agenda_item: @meeting_agenda_item).call(target_id: @target_id, position: @position)end- handle_agenda_item_update_on_move(call, meeting_agenda_item_section, current_occurrence:)+ handle_agenda_item_update_on_move(call, meeting_agenda_item_section, current_occurrence: @current_occurrence)enddef move- current_occurrence = Meeting.find_by(id: params[:current_occurrence])call = ::MeetingAgendaItems::UpdateService.new(user: current_user, model: @meeting_agenda_item).call(move_to: params[:move_to]&.to_sym)if call.success?- move_item_within_section_via_turbo_stream(current_occurrence:)+ move_item_within_section_via_turbo_stream(current_occurrence: @current_occurrence)elsegeneric_call_failure_response(call)end@@ -244,7 +239,7 @@ class MeetingAgendaItemsController < ApplicationControllerenddef move_to_section_dialog- meeting = params[:current_occurrence].present? ? Meeting.find(params[:current_occurrence]) : @meeting_agenda_item.meeting+ meeting = @current_occurrence || @meeting_agenda_item.meetingrespond_with_dialog MeetingAgendaItems::MoveToSectionDialogComponent.new(agenda_item: @meeting_agenda_item,@@ -300,6 +295,10 @@ class MeetingAgendaItemsController < ApplicationController@meeting_agenda_item = MeetingAgendaItem.find(params[:id])end+ def set_current_occurrence+ @current_occurrence = Meeting.find_by(id: params[:current_occurrence])+ end+def meeting_agenda_item_paramsparams.require(:meeting_agenda_item)@@ -340,7 +339,7 @@ class MeetingAgendaItemsController < ApplicationControllerdef assign_drop_params # rubocop:disable Metrics/AbcSize@target_id, @position =if params[:type] == "to_current"- meeting = Meeting.find_by(id: params[:current_occurrence])+ meeting = @current_occurrencesection = meeting.sections.reorder(position: :desc).first[section&.id, section&.last_position]elsif params[:type] == "to_backlog"diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rbindex f7a7a48d2e8..e9ae958cf6d 100644--- a/modules/meeting/app/controllers/meeting_sections_controller.rb+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb@@ -1,4 +1,5 @@# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -36,8 +37,20 @@ class MeetingSectionsController < ApplicationControllerbefore_action :set_meeting_section,except: %i[create clear_backlog clear_backlog_dialog]before_action :set_collapsed_state, only: %i[create cancel_edit destroy]+ before_action :set_current_occurrence, only: %i[clear_backlog clear_backlog_dialog]before_action :authorize+ def edit+ if @meeting_section.editable?+ update_section_header_via_turbo_stream(state: :edit)+ else+ update_all_via_turbo_stream+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))+ end++ respond_with_turbo_streams+ end+def create # rubocop:disable Metrics/AbcSizecall = ::MeetingSections::CreateService.new(user: current_user)@@ -66,17 +79,6 @@ class MeetingSectionsController < ApplicationControllerrespond_with_turbo_streamsend- def edit- if @meeting_section.editable?- update_section_header_via_turbo_stream(state: :edit)- else- update_all_via_turbo_stream- render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))- end-- respond_with_turbo_streams- end-def cancel_editif @meeting_section.untitled? && @meeting_section.agenda_items.empty?# if the section is untitled and no agenda items, we can safely delete it@@ -179,7 +181,6 @@ class MeetingSectionsController < ApplicationControllerenddef clear_backlog- current_occurrence = Meeting.find_by(id: params[:current_occurrence])errors = []meeting_section = @meeting.backlog@meeting.backlog.agenda_items.each do |item|@@ -190,15 +191,15 @@ class MeetingSectionsController < ApplicationControllererrors << call.errors unless call.success?end- update_section_via_turbo_stream(collapsed: true, meeting_section:, current_occurrence: current_occurrence)+ update_section_via_turbo_stream(collapsed: true, meeting_section:, current_occurrence: @current_occurrence)render_error_flash_message_via_turbo_stream(message: t("text_backlog_clear_error")) if errors.any?respond_with_turbo_streamsenddef clear_backlog_dialog- current_occurrence = Meeting.find_by(id: params[:current_occurrence])- respond_with_dialog MeetingSections::Backlogs::ClearBacklogDialogComponent.new(@meeting, current_occurrence:)+ respond_with_dialog MeetingSections::Backlogs::ClearBacklogDialogComponent.new(@meeting,+ current_occurrence: @current_occurrence)endprivate@@ -222,6 +223,10 @@ class MeetingSectionsController < ApplicationController@meeting_section = MeetingSection.find(params[:id])end+ def set_current_occurrence+ @current_occurrence = Meeting.find_by(id: params[:current_occurrence])+ end+def set_collapsed_state@collapsed = ActiveModel::Type::Boolean.new.cast(params[:collapsed])enddiff --git a/modules/meeting/app/forms/meeting/add_to_section.rb b/modules/meeting/app/forms/meeting/add_to_section.rbindex 251bd22d8a9..4e933f6de8e 100644--- a/modules/meeting/app/forms/meeting/add_to_section.rb+++ b/modules/meeting/app/forms/meeting/add_to_section.rb@@ -34,7 +34,7 @@ class Meeting::AddToSection < ApplicationFormname: :meeting_section_id,label: I18n.t("label_add_work_package_to_meeting_section_label"),caption:,- input_width: :large,+ input_width:,autocomplete_options: {decorated: true,defaultData: false,@@ -70,9 +70,9 @@ class Meeting::AddToSection < ApplicationForm@wrapper_id.nil? ? "body" : "##{@wrapper_id}"end- def items+ def items # rubocop:disable Metrics/AbcSizeitems = []- items.concat(meeting.sections) unless meeting.blank? || meeting.templated?+ items.concat(meeting.sections) if meeting.present? && !meeting.templated?items.concat(@occurrence.sections) if @occurrence.present? && @occurrence != meetingitems.push(meeting.backlog) if meeting.present?@@ -109,4 +109,8 @@ class Meeting::AddToSection < ApplicationFormdef captionI18n.t("label_section_selection_caption") if @occurrence.nil?end++ def input_width+ @occurrence.present? ? nil : :large+ endend