Create calendar module

pull/9977/head
Henriette Darge 3 years ago
parent c6723187f0
commit c4ba5fb682
  1. 6
      Gemfile.lock
  2. 1
      Gemfile.modules
  3. 2
      app/views/homescreen/robots.text.erb
  4. 5
      config/initializers/menus.rb
  5. 5
      config/initializers/permissions.rb
  6. 2
      config/initializers/register_views.rb
  7. 2
      config/locales/en.yml
  8. 5
      config/routes.rb
  9. 2
      frontend/src/app/core/path-helper/path-helper.service.ts
  10. 2
      modules/backlogs/lib/open_project/backlogs/engine.rb
  11. 0
      modules/calendar/app/contracts/calendar/views/contract_strategy.rb
  12. 4
      modules/calendar/app/controllers/calendar/base_controller.rb
  13. 12
      modules/calendar/app/controllers/calendar/calendar_controller.rb
  14. 9
      modules/calendar/app/views/calendar/calendar/_menu.html.erb
  15. 0
      modules/calendar/app/views/calendar/calendar/index.html.erb
  16. 4
      modules/calendar/config/locales/en.yml
  17. 7
      modules/calendar/config/routes.rb
  18. 33
      modules/calendar/lib/open_project/calendar.rb
  19. 54
      modules/calendar/lib/open_project/calendar/engine.rb
  20. 1
      modules/calendar/lib/openproject-calendar.rb
  21. 13
      modules/calendar/openproject-calendar.gemspec
  22. 6
      modules/calendar/spec/controllers/calendar_controller_spec.rb
  23. 0
      modules/calendar/spec/features/calendars_spec.rb
  24. 16
      modules/calendar/spec/routing/calendar_routing_spec.rb
  25. 6
      modules/reporting/spec/features/menu_spec.rb
  26. 2
      modules/team_planner/lib/open_project/team_planner/engine.rb
  27. 2
      spec/features/homescreen/robots_spec.rb

@ -68,6 +68,11 @@ PATH
specs:
budgets (1.0.0)
PATH
remote: modules/calendar
specs:
openproject-calendar (1.0.0)
PATH
remote: modules/costs
specs:
@ -1040,6 +1045,7 @@ DEPENDENCIES
openproject-backlogs!
openproject-bim!
openproject-boards!
openproject-calendar!
openproject-documents!
openproject-github_integration!
openproject-job_status!

@ -45,6 +45,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-calendar', path: 'modules/calendar'
gem 'openproject-bim', path: 'modules/bim'
end

@ -34,5 +34,5 @@ Disallow: <%= project_work_packages_path(p) %>
Disallow: <%= project_activity_index_path(p) %>
<% end -%>
<% end %>
Disallow: /work_packages/calendar
Disallow: /calendar
Disallow: /activity

@ -436,11 +436,6 @@ Redmine::MenuManager.map :project_menu do |menu|
last: true,
caption: :label_all_open_wps
menu.push :calendar,
{ controller: '/work_packages/calendars', action: 'index' },
caption: :label_calendar,
icon: 'icon2 icon-calendar'
menu.push :news,
{ controller: '/news', action: 'index' },
caption: :label_news_plural,

@ -344,10 +344,5 @@ OpenProject::AccessControl.map do |map|
require: :loggedin
end
map.project_module :calendar, dependencies: :work_package_tracking do |cal|
cal.permission :view_calendar,
'work_packages/calendars': [:index]
end
map.project_module :activity
end

@ -29,5 +29,3 @@
require Rails.root.join('config/constants/views')
Constants::Views.add :WorkPackagesTable
Constants::Views.add :WorkPackagesCalendar,
contract_strategy: 'Views::CalendarStrategy'

@ -2266,7 +2266,6 @@ en:
permission_select_custom_fields: "Select custom fields"
permission_select_project_modules: "Select project modules"
permission_manage_types: "Select types"
permission_view_calendar: "View calendar"
permission_view_changesets: "View repository revisions in OpenProject"
permission_view_commit_author_statistics: "View commit author statistics"
permission_view_work_package_watchers: "View watchers list"
@ -2306,7 +2305,6 @@ en:
project_module_activity: "Activity"
project_module_forums: "Forums"
project_module_calendar: "Calendar"
project_module_work_package_tracking: "Work package tracking"
project_module_news: "News"
project_module_repository: "Repository"

@ -256,10 +256,6 @@ OpenProject::Application.routes.draw do
# work as a catchall for everything under /wiki
get 'wiki' => 'wiki#show'
namespace :work_packages do
resources :calendar, controller: 'calendars', only: [:index]
end
resources :work_packages, only: [] do
collection do
get '/report/:detail' => 'work_packages/reports#report_details'
@ -437,7 +433,6 @@ OpenProject::Application.routes.draw do
namespace :work_packages do
match 'auto_complete' => 'auto_completes#index', via: %i[get post]
resources :calendar, controller: 'calendars', only: [:index]
resource :bulk, controller: 'bulk', only: %i[edit update destroy]
# FIXME: this is kind of evil!! We need to remove this soonest and
# cover the functionality. Route is being used in work-package-service.js:331

@ -133,7 +133,7 @@ export class PathHelperService {
}
public projectCalendarPath(projectId:string) {
return `${this.projectPath(projectId)}/work_packages/calendar`;
return `${this.projectPath(projectId)}/calendar`;
}
public projectMembershipsPath(projectId:string) {

@ -106,7 +106,7 @@ module OpenProject::Backlogs
:backlogs,
{ controller: '/rb_master_backlogs', action: :index },
caption: :project_module_backlogs,
before: :calendar,
after: :work_packages,
icon: 'icon2 icon-backlogs'
menu :project_menu,

@ -0,0 +1,4 @@
module ::Calendar
class BaseController < ::ApplicationController
end
end

@ -28,11 +28,13 @@
# See COPYRIGHT and LICENSE files for more details.
#++
class WorkPackages::CalendarsController < ApplicationController
menu_item :calendar
before_action :find_optional_project
module ::Calendar
class CalendarController < ApplicationController
menu_item :calendar
before_action :find_optional_project
def index
render layout: 'angular/angular'
def index
render layout: 'angular/angular'
end
end
end

@ -0,0 +1,9 @@
<%=
angular_component_tag 'op-view-select',
inputs: {
projectId: (@project ? @project.id.to_s : ''),
menuItems: [parent_name, name],
baseRoute: 'work-packages.calendar',
viewType: 'WorkPackagesCalendar',
}
%>

@ -0,0 +1,4 @@
# English strings go here
en:
permission_view_calendar: "View calendar"
project_module_calendar_view: "Calendar"

@ -0,0 +1,7 @@
OpenProject::Application.routes.draw do
scope 'projects/:project_id', as: 'project' do
resources :calendar, controller: 'calendar/calendar', only: [:index]
end
resources :calendar, controller: 'calendar/calendar', only: [:index]
end

@ -0,0 +1,33 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 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 Calendar
require 'open_project/calendar/engine'
end
end

@ -0,0 +1,54 @@
# OpenProject Calendar module
#
# Copyright (C) 2021 OpenProject GmbH
#
# 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.
module OpenProject::Calendar
class Engine < ::Rails::Engine
engine_name :openproject_calendar
include OpenProject::Plugins::ActsAsOpEngine
register 'openproject-calendar',
author_url: 'https://www.openproject.org',
bundled: true,
settings: {},
name: 'OpenProject Calendar' do
project_module :calendar_view, dependencies: :work_package_tracking do
permission :view_calendar,
{ 'calendar/calendar': %i[index] }
end
menu :project_menu,
:calendar_view,
{ controller: '/calendar/calendar', action: 'index' },
caption: :label_calendar,
icon: 'icon2 icon-calendar',
after: :work_packages
menu :project_menu,
:calendar_menu,
{ controller: '/calendar/calendar', action: 'index' },
parent: :calendar_view,
partial: 'calendar/calendar/menu',
last: true,
caption: :label_calendar
end
add_view :WorkPackagesCalendar,
contract_strategy: 'Calendar::Views::ContractStrategy'
end
end

@ -0,0 +1 @@
require 'open_project/calendar'

@ -0,0 +1,13 @@
# encoding: UTF-8
Gem::Specification.new do |s|
s.name = 'openproject-calendar'
s.version = '1.0.0'
s.authors = 'OpenProject GmbH'
s.email = 'info@openproject.com'
s.summary = 'OpenProject Calendar'
s.description = 'Provides calendar views'
s.license = 'GPLv3'
s.files = Dir['{app,config,db,lib}/**/*']
end

@ -28,7 +28,7 @@
require 'spec_helper'
describe WorkPackages::CalendarsController, type: :controller do
describe Calendar::CalendarController, type: :controller do
let(:project) do
FactoryBot.build_stubbed(:project).tap do |p|
allow(Project)
@ -42,7 +42,7 @@ describe WorkPackages::CalendarsController, type: :controller do
FactoryBot.build_stubbed(:user).tap do |user|
allow(user)
.to receive(:allowed_to?) do |permission, p, global:|
permission[:controller] == 'work_packages/calendars' &&
permission[:controller] == '/calendar/calendar' &&
permission[:action] == 'index' &&
(p.nil? || p == project)
end
@ -57,7 +57,7 @@ describe WorkPackages::CalendarsController, type: :controller do
it { is_expected.to be_successful }
it { is_expected.to render_template('work_packages/calendars/index') }
it { is_expected.to render_template('calendar/calendar/index') }
end
context 'cross-project' do

@ -28,15 +28,15 @@
require 'spec_helper'
describe WorkPackages::CalendarsController, type: :routing do
it 'should connect GET /work_packages/calendar to work_package/calendar#index' do
expect(get('/work_packages/calendar')).to route_to(controller: 'work_packages/calendars',
action: 'index')
describe Calendar::CalendarController, type: :routing do
it 'should connect GET /calendar to calendar#index' do
expect(get('/calendar')).to route_to(controller: 'calendar/calendar',
action: 'index')
end
it 'should connect GET /project/1/work_packages/calendar to work_package/calendar#index' do
expect(get('/projects/1/work_packages/calendar')).to route_to(controller: 'work_packages/calendars',
action: 'index',
project_id: '1')
it 'should connect GET /project/1/calendar to calendar#index' do
expect(get('/projects/1/calendar')).to route_to(controller: 'calendar/calendar',
action: 'index',
project_id: '1')
end
end

@ -50,7 +50,7 @@ describe 'project menu', type: :feature do
# `url_for controller: 'cost_reports'` will yield different results ...
#
# when on `/projects/ponyo/work_packages`: `/projects/ponyo/cost_reports` (correct)
# when on `/projects/ponyo/work_packages/calendar`: `/work_packages/cost_reports?project_id=ponyo`
# when on `/projects/ponyo/calendar`: `/work_packages/cost_reports?project_id=ponyo`
#
# This is only relevant for project menu entries, not global ones (`project_id` param is nil)*.
# Meaning that you have to make sure to force the absolute URL in a project menu entry
@ -80,7 +80,7 @@ describe 'project menu', type: :feature do
end
context "when on the project's calendar" do
let(:current_path) { '/projects/ponyo/work_packages/calendar' }
let(:current_path) { '/projects/ponyo/calendar' }
it_behaves_like 'it leads to the project costs reports'
end
@ -111,7 +111,7 @@ describe 'project menu', type: :feature do
end
context "when on the project's calendar" do
let(:current_path) { '/projects/ponyo/work_packages/calendar' }
let(:current_path) { '/projects/ponyo/calendar' }
it_behaves_like 'it leads to the cost reports'
end

@ -40,7 +40,7 @@ module OpenProject::TeamPlanner
:team_planner_view,
{ controller: '/team_planner/team_planner', action: :index },
caption: :'team_planner.label_team_planner',
after: :backlogs,
after: :work_packages,
icon: 'icon2 icon-calendar',
badge: 'label_menu_badge.pre_alpha'

@ -36,7 +36,7 @@ describe 'robots.txt', type: :feature do
end
it 'disallows global paths and paths from public project' do
expect(page).to have_content('Disallow: /work_packages/calendar')
expect(page).to have_content('Disallow: /calendar')
expect(page).to have_content('Disallow: /activity')
expect(page).to have_content("Disallow: /projects/#{project.identifier}/repository")

Loading…
Cancel
Save