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

Use the same structure for the submenu of Meetings that we used in other modules

Henriette Darge73efe65a1b0f
diff --git a/modules/meeting/app/controllers/meetings/menus_controller.rb b/modules/meeting/app/controllers/meetings/menus_controller.rb
new file mode 100644
index 00000000000..51c3fd71435
--- /dev/null
+++ b/modules/meeting/app/controllers/meetings/menus_controller.rb
@@ -0,0 +1,43 @@
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-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 Meetings
+ class MenusController < ApplicationController
+ before_action :load_and_authorize_in_optional_project
+
+ def show
+ @submenu_menu_items = ::Meetings::Menu.new(project: @project, params:).menu_items
+ @create_btn_options = if @project.present? && User.current.allowed_in_project?(:create_meetings, @project)
+ { href: new_project_meeting_path(@project), module_key: "meeting" }
+ elsif @project.nil? && User.current.allowed_in_any_project?(:create_meetings)
+ { href: new_meeting_path, module_key: "meeting" }
+ end
+
+ render layout: nil
+ end
+ end
+end
diff --git a/modules/meeting/app/helpers/meetings_helper.rb b/modules/meeting/app/helpers/meetings_helper.rb
index cbf86094711..87b762d685d 100644
--- a/modules/meeting/app/helpers/meetings_helper.rb
+++ b/modules/meeting/app/helpers/meetings_helper.rb
@@ -27,103 +27,6 @@
#++
module MeetingsHelper
- def top_level_sidebar_menu_items
- [
- menu_upcoming_meetings_item,
- menu_past_meetings_item
- ]
- end
-
- def involvement_sidebar_menu_items
- [
- menu_upcoming_invitations_item,
- menu_past_invitations_item,
- menu_attendee_item,
- menu_creator_item
- ]
- end
-
- def menu_upcoming_meetings_item
- path = project_or_global_meetings_path(
- filters: [
- { time: { operator: "=", values: ["future"] } }
- ],
- sort: "start_time"
- )
-
- menu_link_element path, t(:label_upcoming_meetings)
- end
-
- def menu_past_meetings_item
- path = project_or_global_meetings_path(
- filters: [{ time: { operator: "=", values: ["past"] } }],
- sort: "start_time:desc"
- )
-
- menu_link_element path, t(:label_past_meetings)
- end
-
- def menu_upcoming_invitations_item
- path = project_or_global_meetings_path
-
- menu_link_element path, t(:label_upcoming_invitations)
- end
-
- def menu_past_invitations_item
- path = project_or_global_meetings_path(
- filters: [
- { time: { operator: "=", values: ["past"] } },
- { invited_user_id: { operator: "=", values: [User.current.id.to_s] } }
- ],
- sort: "start_time:desc"
- )
-
- menu_link_element path, t(:label_past_invitations)
- end
-
- def menu_attendee_item
- path = project_or_global_meetings_path(
- filters: [{ attended_user_id: { operator: "=", values: [User.current.id.to_s] } }]
- )
-
- menu_link_element path, t(:label_attendee)
- end
-
- def menu_creator_item
- path = project_or_global_meetings_path(
- filters: [{ author_id: { operator: "=", values: [User.current.id.to_s] } }]
- )
-
- menu_link_element path, t(:label_author)
- end
-
- def project_or_global_meetings_path(filters: nil, sort: nil)
- return polymorphic_path([@project, :meetings]) if filters.blank? && sort.blank?
-
- query_params = {}.tap do |query|
- query[:filters] = filters.to_json if filters.present?
- query[:sort] = sort if sort.present?
- end
-
- polymorphic_path([@project, :meetings], query_params)
- end
-
- def menu_link_element(path, label)
- link_to path, class: menu_item_css_class(path), title: label do
- content_tag(:span, class: "op-sidemenu--item-title") do
- label
- end
- end
- end
-
- def menu_item_css_class(path)
- "op-sidemenu--item-action#{menu_item_selected(path) ? ' selected' : ''}"
- end
-
- def menu_item_selected(menu_item_path)
- menu_item_path == request.fullpath
- end
-
def format_participant_list(participants)
if participants.any?
user_links = participants
diff --git a/modules/meeting/app/menus/meetings/menu.rb b/modules/meeting/app/menus/meetings/menu.rb
new file mode 100644
index 00000000000..e7275f8822a
--- /dev/null
+++ b/modules/meeting/app/menus/meetings/menu.rb
@@ -0,0 +1,86 @@
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2010-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 Meetings
+ class Menu < Submenu
+ attr_reader :view_type, :project
+
+ def initialize(project: nil, params: nil)
+ @project = project
+ @params = params
+
+ super(view_type:, project:, params:)
+ end
+
+ def menu_items
+ [
+ OpenProject::Menu::MenuGroup.new(header: nil, children: top_level_menu_items),
+ OpenProject::Menu::MenuGroup.new(header: I18n.t(:label_involvement), children: involvement_sidebar_menu_items)
+ ]
+ end
+
+ def top_level_menu_items
+ upcoming_filter = [{ time: { operator: "=", values: ["future"] } }].to_json
+ past_filter = [{ time: { operator: "=", values: ["past"] } }].to_json
+
+ [
+ menu_item({ filters: upcoming_filter, sort: "start_time" },
+ I18n.t(:label_upcoming_meetings)),
+ menu_item({ filters: past_filter, sort: "start_time:desc" },
+ I18n.t(:label_past_meetings))
+ ]
+ end
+
+ def involvement_sidebar_menu_items
+ past_filter = [
+ { time: { operator: "=", values: ["past"] } },
+ { invited_user_id: { operator: "=", values: [User.current.id.to_s] } }
+ ].to_json
+ attendee_filter = [{ attended_user_id: { operator: "=", values: [User.current.id.to_s] } }].to_json
+ author_filter = [{ author_id: { operator: "=", values: [User.current.id.to_s] } }].to_json
+
+ [
+ menu_item({},
+ I18n.t(:label_upcoming_invitations)),
+ menu_item({ filters: past_filter, sort: "start_time:desc" },
+ I18n.t(:label_past_invitations)),
+ menu_item({ filters: attendee_filter },
+ I18n.t(:label_attendee)),
+ menu_item({ filters: author_filter },
+ I18n.t(:label_author))
+ ]
+ end
+
+ def query_path(query_params)
+ if project.present?
+ project_meetings_path(project, params.permit(query_params.keys).merge!(query_params))
+ else
+ meetings_path(params.permit(query_params.keys).merge!(query_params))
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/views/meetings/_menu_query_select.html.erb b/modules/meeting/app/views/meetings/_menu_query_select.html.erb
deleted file mode 100644
index 812a78d211f..00000000000
--- a/modules/meeting/app/views/meetings/_menu_query_select.html.erb
+++ /dev/null
@@ -1,79 +0,0 @@
-<%#-- copyright
-OpenProject is an open source project management software.
-Copyright (C) 2012-2024 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.
-
-++#%>
-
-<div class="op-sidebar">
- <div class="op-sidebar--body">
- <div class="op-sidemenu">
- <ul class="op-sidemenu--items">
- <% top_level_sidebar_menu_items.each do |menu_item| %>
- <li class="op-sidemenu--item">
- <%= menu_item %>
- </li>
- <% end %>
- </ul>
-
- <div class="op-sidemenu"
- data-controller="menus--expandable-sidemenu"
- data-application-target="dynamic">
-
- <button class="op-sidemenu--title"
- type="button"
- data-action="click->menus--expandable-sidemenu#toggleContainer">
- <%= t(:label_involvement) %>
- <span class="icon-small icon-arrow-up1"
- aria-hidden="true"
- data-menus--expandable-sidemenu-target="indicator">
- </span>
- </button>
-
- <ul class="op-sidemenu--items"
- data-menus--expandable-sidemenu-target="container">
- <% involvement_sidebar_menu_items.each do |menu_item| %>
- <li class="op-sidemenu--item">
- <%= menu_item %>
- </li>
- <% end %>
- </ul>
- </div>
- </div>
- </div>
-
- <div class="op-sidebar--footer">
- <% if (@project && User.current.allowed_in_project?(:create_meetings, @project)) || (@project.nil? && User.current.allowed_in_any_project?(:create_meetings)) %>
- <%= button_to polymorphic_path([:new, @project, :meeting]),
- { method: :get,
- class: 'button -primary -expand',
- aria: { label: t(:label_meeting_new) },
- title: t(:label_meeting_new) } do %>
- <%= spot_icon('add') %>
- <span><%= t(:label_meeting) %></span>
- <% end %>
- <% end %>
- </div>
-</div>
diff --git a/modules/meeting/app/views/meetings/menus/_menu.html.erb b/modules/meeting/app/views/meetings/menus/_menu.html.erb
new file mode 100644
index 00000000000..34018e7e1a8
--- /dev/null
+++ b/modules/meeting/app/views/meetings/menus/_menu.html.erb
@@ -0,0 +1,5 @@
+ <%= turbo_frame_tag "meeting_sidemenu",
+ src: @project.present? ? menu_project_meetings_path(@project) : meetings_menu_path(),
+ target: '_top',
+ data: { turbo: false },
+ loading: :lazy %>
diff --git a/modules/meeting/app/views/meetings/menus/show.html.erb b/modules/meeting/app/views/meetings/menus/show.html.erb
new file mode 100644
index 00000000000..84fcb51f501
--- /dev/null
+++ b/modules/meeting/app/views/meetings/menus/show.html.erb
@@ -0,0 +1,4 @@
+<%= turbo_frame_tag "meeting_sidemenu" do %>
+ <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items,
+ create_btn_options: @create_btn_options) %>
+<% end %>
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 0044abb9ec4..9a23450880a 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -28,7 +28,11 @@
Rails.application.routes.draw do
resources :projects, only: %i[] do
- resources :meetings, only: %i[index new create show]
+ resources :meetings, only: %i[index new create show] do
+ collection do
+ get "menu" => "meetings/menus#show"
+ end
+ end
end
resources :work_packages, only: %i[] do
@@ -47,6 +51,10 @@ Rails.application.routes.draw do
end
end
+ namespace :meetings do
+ resource :menu, only: %[show]
+ end
+
resources :meetings do
member do
get :cancel_edit
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index d2a26c53b74..0669e093360 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -43,10 +43,12 @@ module OpenProject::Meeting
{ meetings: %i[index show download_ics participants_dialog history],
meeting_agendas: %i[history show diff],
meeting_minutes: %i[history show diff],
+ "meetings/menus": %i[show],
work_package_meetings_tab: %i[index count] },
permissible_on: :project
permission :create_meetings,
- { meetings: %i[new create copy] },
+ { meetings: %i[new create copy],
+ "meetings/menus": %i[show] },
permissible_on: :project,
require: :member,
contract_actions: { meetings: %i[create] }
@@ -120,7 +122,7 @@ module OpenProject::Meeting
menu :project_menu,
:meetings_query_select, { controller: "/meetings", action: "index" },
parent: :meetings,
- partial: "meetings/menu_query_select"
+ partial: "meetings/menus/menu"
should_render_global_menu_item = Proc.new do
(User.current.logged? || !Setting.login_required?) &&
@@ -145,7 +147,7 @@ module OpenProject::Meeting
menu :global_menu,
:meetings_query_select, { controller: "/meetings", action: "index", project_id: nil },
parent: :meetings,
- partial: "meetings/menu_query_select",
+ partial: "meetings/menus/menu",
if: should_render_global_menu_item
ActiveSupport::Inflector.inflections do |inflect|