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
Implement rails based side menu for the calendars module
Henriette Dargeb6ec7c0524a3
diff --git a/modules/calendar/app/controllers/calendar/menus_controller.rb b/modules/calendar/app/controllers/calendar/menus_controller.rbnew file mode 100644index 00000000000..d500883d311--- /dev/null+++ b/modules/calendar/app/controllers/calendar/menus_controller.rb@@ -0,0 +1,39 @@+# -- 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 ::Calendar+ class MenusController < ApplicationController+ before_action :find_project_by_project_id,+ :authorize++ def show+ @submenu_menu_items = ::Calendar::Menu.new(project: @project, params:).menu_items++ render layout: nil+ end+ end+enddiff --git a/modules/calendar/app/helpers/calendar/menu.rb b/modules/calendar/app/helpers/calendar/menu.rbnew file mode 100644index 00000000000..73d346aa521--- /dev/null+++ b/modules/calendar/app/helpers/calendar/menu.rb@@ -0,0 +1,52 @@+# -- 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 Calendar+ class Menu < Menus::Submenu+ attr_reader :view_type, :project++ def initialize(project: nil, params: nil)+ @view_type = "work_packages_calendar"+ @project = project+ @params = params++ super(view_type:, project:, params:)+ end++ def default_queries+ []+ end++ def query_params(id)+ { id: }+ end++ def query_path(query_params)+ project_calendar_path(project, query_params)+ end+ end+enddiff --git a/modules/calendar/app/views/calendar/menus/_menu.html.erb b/modules/calendar/app/views/calendar/menus/_menu.html.erbnew file mode 100644index 00000000000..972fe4c353d--- /dev/null+++ b/modules/calendar/app/views/calendar/menus/_menu.html.erb@@ -0,0 +1,5 @@+ <%= turbo_frame_tag "calendar_sidemenu",+ src: @project ? menu_project_calendars_path(@project) : calendars_menu_path(),+ target: '_top',+ data: { turbo: false },+ loading: :lazy %>diff --git a/modules/calendar/app/views/calendar/menus/show.html.erb b/modules/calendar/app/views/calendar/menus/show.html.erbnew file mode 100644index 00000000000..a65dd2af4a4--- /dev/null+++ b/modules/calendar/app/views/calendar/menus/show.html.erb@@ -0,0 +1,3 @@+<%= turbo_frame_tag "calendar_sidemenu" do %>+ <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items, searchable: true) %>+<% end %>diff --git a/modules/calendar/config/routes.rb b/modules/calendar/config/routes.rbindex 42322035b02..95469b1666a 100644--- a/modules/calendar/config/routes.rb+++ b/modules/calendar/config/routes.rb@@ -4,6 +4,9 @@ Rails.application.routes.draw docontroller: "calendar/calendars",only: %i[index destroy],as: :calendars do+ collection do+ get "menu" => "calendar/menus#show"+ endget "/new" => "calendar/calendars#show", on: :collection, as: "new"get "/ical" => "calendar/ical#show", on: :member, as: "ical"get "(/*state)" => "calendar/calendars#show", on: :member, as: ""@@ -11,4 +14,8 @@ Rails.application.routes.draw doendresources :calendars, only: %i[index new create], controller: "calendar/calendars"++ namespace :calendars do+ resource :menu, only: %[show]+ endenddiff --git a/modules/calendar/lib/open_project/calendar/engine.rb b/modules/calendar/lib/open_project/calendar/engine.rbindex 36d907c9bba..287d4ce569c 100644--- a/modules/calendar/lib/open_project/calendar/engine.rb+++ b/modules/calendar/lib/open_project/calendar/engine.rb@@ -28,7 +28,8 @@ module OpenProject::Calendarsettings: {} doproject_module :calendar_view, dependencies: :work_package_tracking dopermission :view_calendar,- { "calendar/calendars": %i[index show] },+ { "calendar/calendars": %i[index show],+ "calendar/menus": %i[show] },permissible_on: :project,dependencies: %i[view_work_packages],contract_actions: { calendar: %i[read] }@@ -76,7 +77,7 @@ module OpenProject::Calendar:calendar_menu,{ controller: "/calendar/calendars", action: "index" },parent: :calendar_view,- partial: "calendar/calendars/menu",+ partial: "calendar/menus/menu",last: true,caption: :label_calendar_pluralend