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

Create a separate Gantt module, with an own view identifier and menu node. Currently the module is still redirecting to the work package module. Later it will get it's own routing.

Henriette Dargeb64cae01b4ad
diff --git a/Gemfile.lock b/Gemfile.lock
index 107ac23469a..1b187a2fdf2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -122,6 +122,11 @@ PATH
specs:
openproject-documents (1.0.0)
+PATH
+ remote: modules/gantt
+ specs:
+ openproject-gantt (1.0.0)
+
PATH
remote: modules/github_integration
specs:
@@ -1148,6 +1153,7 @@ DEPENDENCIES
openproject-boards!
openproject-calendar!
openproject-documents!
+ openproject-gantt!
openproject-github_integration!
openproject-job_status!
openproject-ldap_groups!
diff --git a/Gemfile.modules b/Gemfile.modules
index 0fc99facde8..6e8a38a26e8 100644
--- a/Gemfile.modules
+++ b/Gemfile.modules
@@ -44,6 +44,7 @@ group :opf_plugins do
gem 'overviews', path: 'modules/overviews'
gem 'budgets', path: 'modules/budgets'
gem 'openproject-team_planner', path: 'modules/team_planner'
+ gem 'openproject-gantt', path: 'modules/gantt'
gem 'openproject-calendar', path: 'modules/calendar'
gem 'openproject-storages', path: 'modules/storages'
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index e4e0ea01545..546bb7b7a6d 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -546,7 +546,7 @@ Redmine::MenuManager.map :project_menu do |menu|
menu.push :work_packages,
{ controller: '/work_packages', action: 'index' },
caption: :label_work_package_plural,
- icon: 'view-timeline',
+ icon: 'view-list',
html: {
id: 'main-menu-work-packages',
'wp-query-menu': 'wp-query-menu'
diff --git a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
index 3eb5aafeaad..8c20c3bbb65 100644
--- a/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
+++ b/frontend/src/app/shared/components/op-view-select/op-static-queries.service.ts
@@ -126,15 +126,6 @@ export class StaticQueriesService {
},
view: 'WorkPackagesTable',
},
- {
- title: this.text.gantt,
- uiSref: 'work-packages',
- uiParams: {
- query_id: '',
- query_props: '{"c":["id","type","subject","status","startDate","dueDate","duration"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}',
- },
- view: 'WorkPackagesTable',
- },
{
title: this.text.overdue,
uiSref: 'work-packages',
@@ -171,6 +162,16 @@ export class StaticQueriesService {
},
view: 'Bim',
},
+ {
+ title: this.text.gantt,
+ // TODO: GANTT
+ uiSref: 'work-packages',
+ uiParams: {
+ query_id: '',
+ query_props: '{"c":["id","type","subject","status","startDate","dueDate","duration"],"tv":true,"tzl":"auto","tll":"{\\"left\\":\\"startDate\\",\\"right\\":\\"dueDate\\",\\"farRight\\":\\"subject\\"}","hi":true,"g":"","t":"startDate:asc","f":[{"n":"status","o":"o","v":[]}]}',
+ },
+ view: 'Gantt',
+ },
];
const projectIdentifier = this.CurrentProject.identifier;
diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts b/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts
index 3e0853aa917..49ac2c26f70 100644
--- a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts
+++ b/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts
@@ -53,7 +53,7 @@ import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { ApiV3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';
import { MAGIC_PAGE_NUMBER } from 'core-app/core/apiv3/helpers/get-paginated-results';
-export type ViewType = 'WorkPackagesTable'|'Bim'|'TeamPlanner'|'WorkPackagesCalendar';
+export type ViewType = 'WorkPackagesTable'|'Bim'|'TeamPlanner'|'WorkPackagesCalendar'|'Gantt';
export const opViewSelectSelector = 'op-view-select';
diff --git a/modules/gantt/app/contracts/gantt/views/contract_strategy.rb b/modules/gantt/app/contracts/gantt/views/contract_strategy.rb
new file mode 100644
index 00000000000..98b24517d21
--- /dev/null
+++ b/modules/gantt/app/contracts/gantt/views/contract_strategy.rb
@@ -0,0 +1,30 @@
+module ::Gantt
+ module Views
+ class ContractStrategy < ::BaseContract
+ validate :manageable
+
+ private
+
+ def manageable
+ return if model.query.blank?
+
+ errors.add(:base, :error_unauthorized) unless query_permissions?
+ end
+
+ def query_permissions?
+ # The visibility i.e. whether a private query belongs to the user is checked via the
+ # query_visible? method.
+ (model.query.public && user_allowed_on_query?(:manage_public_queries)) ||
+ (!model.query.public && user_allowed_on_query?(:save_queries))
+ end
+
+ def user_allowed_on_query?(permission)
+ if model.query.project
+ user.allowed_in_project?(permission, model.query.project)
+ else
+ user.allowed_in_any_project?(permission)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/gantt/app/controllers/gantt/base_controller.rb b/modules/gantt/app/controllers/gantt/base_controller.rb
new file mode 100644
index 00000000000..ff5c343fd44
--- /dev/null
+++ b/modules/gantt/app/controllers/gantt/base_controller.rb
@@ -0,0 +1,4 @@
+module ::Gantt
+ class BaseController < ::ApplicationController
+ end
+end
diff --git a/modules/gantt/app/controllers/gantt/gantt_controller.rb b/modules/gantt/app/controllers/gantt/gantt_controller.rb
new file mode 100644
index 00000000000..57c73096eba
--- /dev/null
+++ b/modules/gantt/app/controllers/gantt/gantt_controller.rb
@@ -0,0 +1,5 @@
+module ::Gantt
+ class GanttController < BaseController
+ menu_item :gantt
+ end
+end
diff --git a/modules/gantt/app/views/gantt/gantt/_menu.html.erb b/modules/gantt/app/views/gantt/gantt/_menu.html.erb
new file mode 100644
index 00000000000..201d91c0b84
--- /dev/null
+++ b/modules/gantt/app/views/gantt/gantt/_menu.html.erb
@@ -0,0 +1,12 @@
+<div class="op-sidebar">
+ <%=
+ angular_component_tag 'op-view-select',
+ inputs: {
+ projectId: (@project ? @project.id.to_s : ''),
+ menuItems: [parent_name, name],
+ baseRoute: 'work-packages',
+ viewType: 'Gantt',
+ },
+ class: 'op-sidebar--body'
+ %>
+</div>
diff --git a/modules/gantt/config/routes.rb b/modules/gantt/config/routes.rb
new file mode 100644
index 00000000000..4b187994b18
--- /dev/null
+++ b/modules/gantt/config/routes.rb
@@ -0,0 +1,2 @@
+# OpenProject::Application.routes.draw do
+# end
diff --git a/modules/gantt/lib/open_project/gantt.rb b/modules/gantt/lib/open_project/gantt.rb
new file mode 100644
index 00000000000..8ec76b844c2
--- /dev/null
+++ b/modules/gantt/lib/open_project/gantt.rb
@@ -0,0 +1,33 @@
+#-- 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 OpenProject
+ module Gantt
+ require 'open_project/gantt/engine'
+ end
+end
diff --git a/modules/gantt/lib/open_project/gantt/engine.rb b/modules/gantt/lib/open_project/gantt/engine.rb
new file mode 100644
index 00000000000..8e6c9eee12c
--- /dev/null
+++ b/modules/gantt/lib/open_project/gantt/engine.rb
@@ -0,0 +1,84 @@
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2021-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 OpenProject::Gantt
+ class Engine < ::Rails::Engine
+ engine_name :openproject_gantt
+
+ include OpenProject::Plugins::ActsAsOpEngine
+
+ register 'openproject-gantt',
+ author_url: 'https://www.openproject.org',
+ bundled: true,
+ settings: {} do
+ # should_render_global_menu_item = Proc.new do
+ # (User.current.logged? || !Setting.login_required?) &&
+ # User.current.allowed_in_any_project?(:view_work_packages)
+ # end
+
+ # menu :global_menu,
+ # :gantt,
+ # { controller: '/work_packages', action: 'index' },
+ # caption: :label_gantt,
+ # icon: 'view-timeline',
+ # html: {
+ # id: 'main-menu-gantt',
+ # }
+
+ menu :project_menu,
+ :gantt,
+ { controller: '/work_packages', action: 'index' },
+ caption: :label_gantt,
+ after: :work_packages,
+ icon: 'view-timeline',
+ html: {
+ id: 'main-menu-gantt'
+ }
+
+ menu :project_menu,
+ :gantt_query_select,
+ { controller: '/work_packages', action: 'index' },
+ parent: :gantt,
+ partial: 'gantt/gantt/menu',
+ last: true,
+ caption: :label_gantt_chart
+
+ # menu :top_menu,
+ # :gantt,
+ # { controller: '/work_packages', action: 'index' },
+ # caption: :label_gantt,
+ # icon: 'view-timeline',
+ # html: {
+ # id: 'main-menu-gantt',
+ # }
+ end
+
+ add_view :Gantt,
+ contract_strategy: 'Gantt::Views::ContractStrategy'
+ end
+end
diff --git a/modules/gantt/lib/openproject-gantt.rb b/modules/gantt/lib/openproject-gantt.rb
new file mode 100644
index 00000000000..95933c137e0
--- /dev/null
+++ b/modules/gantt/lib/openproject-gantt.rb
@@ -0,0 +1 @@
+require 'open_project/gantt'
diff --git a/modules/gantt/openproject-gantt.gemspec b/modules/gantt/openproject-gantt.gemspec
new file mode 100644
index 00000000000..bf96d10b96c
--- /dev/null
+++ b/modules/gantt/openproject-gantt.gemspec
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = 'openproject-gantt'
+ s.version = '1.0.0'
+ s.authors = 'OpenProject GmbH'
+ s.email = '[email protected]'
+ s.summary = 'OpenProject Gantt'
+ s.description = 'Provides gantt views'
+ s.license = 'GPLv3'
+
+ s.files = Dir['{app,config,db,lib}/**/*']
+ s.metadata['rubygems_mfa_required'] = 'true'
+end