Merge pull request #9977 from opf/feature/36322-Save-different-views-in-calendar-module
[36322] Save different views in calendar modulepull/10032/head
commit
dc479cbbe0
@ -0,0 +1,75 @@ |
||||
// -- 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.
|
||||
//++
|
||||
|
||||
import { Ng2StateDeclaration } from '@uirouter/angular'; |
||||
import { makeSplitViewRoutes } from 'core-app/features/work-packages/routing/split-view-routes.template'; |
||||
import { WorkPackageSplitViewComponent } from 'core-app/features/work-packages/routing/wp-split-view/wp-split-view.component'; |
||||
import { WorkPackagesBaseComponent } from 'core-app/features/work-packages/routing/wp-base/wp--base.component'; |
||||
import { WorkPackagesCalendarComponent } from 'core-app/features/calendar/wp-calendar/wp-calendar.component'; |
||||
import { WorkPackagesCalendarPageComponent } from 'core-app/features/calendar/wp-calendar-page/wp-calendar-page.component'; |
||||
|
||||
export const CALENDAR_ROUTES:Ng2StateDeclaration[] = [ |
||||
{ |
||||
name: 'calendar', |
||||
parent: 'optional_project', |
||||
url: '/calendar?query_id&query_props&cdate&cview', |
||||
redirectTo: 'calendar.page', |
||||
views: { |
||||
'!$default': { component: WorkPackagesBaseComponent }, |
||||
}, |
||||
params: { |
||||
query_id: { type: 'query', dynamic: true }, |
||||
cdate: { type: 'string', dynamic: true }, |
||||
cview: { type: 'string', dynamic: true }, |
||||
// Use custom encoder/decoder that ensures validity of URL string
|
||||
query_props: { type: 'opQueryString' }, |
||||
}, |
||||
}, |
||||
{ |
||||
name: 'calendar.page', |
||||
component: WorkPackagesCalendarPageComponent, |
||||
redirectTo: 'calendar.page.show', |
||||
data: { |
||||
bodyClasses: 'router--calendar', |
||||
}, |
||||
}, |
||||
{ |
||||
name: 'calendar.page.show', |
||||
data: { |
||||
baseRoute: 'calendar.page.show', |
||||
}, |
||||
views: { |
||||
'content-left': { component: WorkPackagesCalendarComponent }, |
||||
}, |
||||
}, |
||||
...makeSplitViewRoutes( |
||||
'calendar.page.show', |
||||
undefined, |
||||
WorkPackageSplitViewComponent, |
||||
), |
||||
]; |
@ -0,0 +1,130 @@ |
||||
// -- 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.
|
||||
//++
|
||||
|
||||
import { |
||||
ChangeDetectionStrategy, |
||||
Component, |
||||
ViewChild, |
||||
} from '@angular/core'; |
||||
import { WorkPackagesCalendarComponent } from 'core-app/features/calendar/wp-calendar/wp-calendar.component'; |
||||
import { |
||||
DynamicComponentDefinition, |
||||
PartitionedQuerySpacePageComponent, |
||||
ToolbarButtonComponentDefinition, |
||||
ViewPartitionState, |
||||
} from 'core-app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component'; |
||||
import { WorkPackageFilterContainerComponent } from 'core-app/features/work-packages/components/filters/filter-container/filter-container.directive'; |
||||
import { WorkPackageFilterButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-filter-button/wp-filter-button.component'; |
||||
import { ZenModeButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/zen-mode-toggle-button/zen-mode-toggle-button.component'; |
||||
import { WorkPackageSettingsButtonComponent } from 'core-app/features/work-packages/components/wp-buttons/wp-settings-button/wp-settings-button.component'; |
||||
import { QueryResource } from 'core-app/features/hal/resources/query-resource'; |
||||
import { QueryParamListenerService } from 'core-app/features/work-packages/components/wp-query/query-param-listener.service'; |
||||
|
||||
@Component({ |
||||
templateUrl: '../../work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html', |
||||
styleUrls: [ |
||||
'../../work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.sass', |
||||
], |
||||
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
providers: [ |
||||
QueryParamListenerService, |
||||
], |
||||
}) |
||||
export class WorkPackagesCalendarPageComponent extends PartitionedQuerySpacePageComponent { |
||||
@ViewChild(WorkPackagesCalendarComponent, { static: true }) calendarElement:WorkPackagesCalendarComponent; |
||||
|
||||
text = { |
||||
title: this.I18n.t('js.calendar.title'), |
||||
unsaved_title: this.I18n.t('js.calendar.unsaved_title'), |
||||
}; |
||||
|
||||
/** Go back using back-button */ |
||||
backButtonCallback:() => void; |
||||
|
||||
/** Current query title to render */ |
||||
selectedTitle = this.text.unsaved_title; |
||||
|
||||
filterContainerDefinition:DynamicComponentDefinition = { |
||||
component: WorkPackageFilterContainerComponent, |
||||
}; |
||||
|
||||
/** We need to pass the correct partition state to the view to manage the grid */ |
||||
currentPartition:ViewPartitionState = '-split'; |
||||
|
||||
/** Show a toolbar */ |
||||
showToolbar = true; |
||||
|
||||
/** Toolbar is not editable */ |
||||
titleEditingEnabled = false; |
||||
|
||||
/** Savable */ |
||||
showToolbarSaveButton = true; |
||||
|
||||
/** Toolbar is always enabled */ |
||||
toolbarDisabled = false; |
||||
|
||||
/** Define the buttons shown in the toolbar */ |
||||
toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [ |
||||
{ |
||||
component: WorkPackageFilterButtonComponent, |
||||
}, |
||||
{ |
||||
component: ZenModeButtonComponent, |
||||
}, |
||||
{ |
||||
component: WorkPackageSettingsButtonComponent, |
||||
containerClasses: 'hidden-for-mobile', |
||||
show: ():boolean => this.authorisationService.can('query', 'updateImmediately'), |
||||
inputs: { |
||||
hideTableOptions: true, |
||||
}, |
||||
}, |
||||
]; |
||||
|
||||
/** |
||||
* We need to set the current partition to the grid to ensure |
||||
* either side gets expanded to full width if we're not in '-split' mode. |
||||
* |
||||
* @param state The current or entering state |
||||
*/ |
||||
setPartition(state:{ data:{ partition?:ViewPartitionState } }):void { |
||||
this.currentPartition = state.data?.partition || '-split'; |
||||
} |
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
protected staticQueryName(query:QueryResource):string { |
||||
return this.text.unsaved_title; |
||||
} |
||||
|
||||
/** |
||||
* @protected |
||||
*/ |
||||
protected loadInitialQuery():void { |
||||
// We never load the initial query as the calendar service does all that.
|
||||
} |
||||
} |
@ -0,0 +1,17 @@ |
||||
<div class="op-wp-calendar" |
||||
data-qa-selector="op-wp-calendar" |
||||
[attr.data-indicator-name]="'table'"> |
||||
<ng-container |
||||
*ngIf="(calendarOptions$ | async) as calendarOptions" |
||||
> |
||||
<full-calendar |
||||
#ucCalendar |
||||
*ngIf="calendarOptions" |
||||
[options]="calendarOptions" |
||||
></full-calendar> |
||||
</ng-container> |
||||
<div |
||||
*ngIf="static" |
||||
[textContent]="calendar.tooManyResultsText" |
||||
class="op-wp-calendar--notification"></div> |
||||
</div> |
@ -1,27 +0,0 @@ |
||||
<div class="work-packages-calendar-view--container loading-indicator--location" |
||||
data-indicator-name="calendar-entry"> |
||||
<div class="toolbar-container -editable"> |
||||
<div class="toolbar"> |
||||
<div class="title-container"> |
||||
<h2> |
||||
{{ I18n.t('js.calendar.title') }} |
||||
</h2> |
||||
</div> |
||||
|
||||
<ul class="toolbar-items hide-when-print"> |
||||
<li class="toolbar-item hidden-for-mobile"> |
||||
<wp-filter-button> |
||||
</wp-filter-button> |
||||
</li> |
||||
<li class="toolbar-item hidden-for-mobile"> |
||||
<zen-mode-toggle-button> |
||||
</zen-mode-toggle-button> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
|
||||
<filter-container></filter-container> |
||||
|
||||
<wp-calendar [projectIdentifier]="projectIdentifier"></wp-calendar> |
||||
</div> |
@ -1,14 +0,0 @@ |
||||
<!-- position: relative added in order for the loading indicator to be positioned correctly --> |
||||
<div class="op-wp-calendar loading-indicator--location" |
||||
data-qa-selector="op-wp-calendar" |
||||
[attr.data-indicator-name]="'table'" |
||||
style="position: relative"> |
||||
<full-calendar #ucCalendar |
||||
*ngIf="calendarOptions" |
||||
[options]="calendarOptions"> |
||||
</full-calendar> |
||||
<div |
||||
*ngIf="static" |
||||
[textContent]="calendar.tooManyResultsText" |
||||
class="op-wp-calendar--notification"></div> |
||||
</div> |
@ -0,0 +1,3 @@ |
||||
.router--calendar |
||||
#content |
||||
height: 100% |
@ -0,0 +1,23 @@ |
||||
module ::Calendar |
||||
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? |
||||
user_allowed_on_query?(:view_calendar) |
||||
end |
||||
|
||||
def user_allowed_on_query?(permission) |
||||
user.allowed_to?(permission, model.query.project, global: model.query.project.nil?) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,4 @@ |
||||
module ::Calendar |
||||
class BaseController < ::ApplicationController |
||||
end |
||||
end |
@ -0,0 +1,40 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- 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 ::Calendar |
||||
class CalendarController < ApplicationController |
||||
menu_item :calendar_view |
||||
before_action :find_optional_project |
||||
|
||||
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: 'calendar.page.show', |
||||
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 @@ |
||||
# English strings go here |
||||
en: |
||||
js: |
||||
calendar: |
||||
title: 'Calendar' |
||||
too_many: 'There are %{count} work packages in total, but only %{max} can be shown.' |
||||
unsaved_title: 'Unnamed calendar' |
@ -0,0 +1,7 @@ |
||||
OpenProject::Application.routes.draw do |
||||
scope 'projects/:project_id', as: 'project' do |
||||
get '/calendar(/*state)', to: 'calendar/calendar#index', as: :calendar |
||||
end |
||||
|
||||
get '/calendar(/*state)', to: 'calendar/calendar#index', as: :calendar |
||||
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 |
@ -0,0 +1,143 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- 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. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
require_relative '../support/pages/calendar' |
||||
require_relative '../../../../spec/features/views/shared_examples' |
||||
|
||||
describe 'Calendar query handling', type: :feature, js: true do |
||||
shared_let(:type_task) { FactoryBot.create(:type_task) } |
||||
shared_let(:type_bug) { FactoryBot.create(:type_bug) } |
||||
shared_let(:project) do |
||||
FactoryBot.create(:project, |
||||
enabled_module_names: %w[work_package_tracking calendar_view], |
||||
types: [type_task, type_bug]) |
||||
end |
||||
|
||||
shared_let(:user) do |
||||
FactoryBot.create :user, |
||||
member_in_project: project, |
||||
member_with_permissions: %w[ |
||||
view_work_packages |
||||
edit_work_packages |
||||
save_queries |
||||
save_public_queries |
||||
view_calendar |
||||
] |
||||
end |
||||
|
||||
shared_let(:task) do |
||||
FactoryBot.create :work_package, |
||||
project: project, |
||||
type: type_task, |
||||
assigned_to: user, |
||||
start_date: Time.zone.today - 1.day, |
||||
due_date: Time.zone.today + 1.day, |
||||
subject: 'A task for the user' |
||||
end |
||||
shared_let(:bug) do |
||||
FactoryBot.create :work_package, |
||||
project: project, |
||||
type: type_bug, |
||||
assigned_to: user, |
||||
start_date: Time.zone.today - 1.day, |
||||
due_date: Time.zone.today + 1.day, |
||||
subject: 'A bug for the user' |
||||
end |
||||
|
||||
shared_let(:saved_query) do |
||||
FactoryBot.create(:query_with_view_work_packages_calendar, |
||||
project: project, |
||||
public: true) |
||||
end |
||||
|
||||
let(:calendar_page) { ::Pages::Calendar.new project } |
||||
let(:work_package_page) { ::Pages::WorkPackagesTable.new project } |
||||
let(:query_title) { ::Components::WorkPackages::QueryTitle.new } |
||||
let(:query_menu) { ::Components::WorkPackages::QueryMenu.new } |
||||
let(:filters) { calendar_page.filters } |
||||
|
||||
current_user { user } |
||||
|
||||
before do |
||||
login_as user |
||||
calendar_page.visit! |
||||
|
||||
loading_indicator_saveguard |
||||
|
||||
calendar_page.expect_event task |
||||
calendar_page.expect_event bug |
||||
end |
||||
|
||||
it 'allows saving the calendar' do |
||||
filters.expect_filter_count("1") |
||||
filters.open |
||||
|
||||
filters.add_filter_by('Type', 'is', [type_bug.name]) |
||||
|
||||
filters.expect_filter_count("2") |
||||
|
||||
calendar_page.expect_event bug |
||||
calendar_page.expect_event task, present: false |
||||
|
||||
query_title.expect_changed |
||||
query_title.press_save_button |
||||
|
||||
calendar_page.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_create')) |
||||
end |
||||
|
||||
it 'shows only calendar queries' do |
||||
# Go to calendar where a query is already shown |
||||
query_menu.expect_menu_entry saved_query.name |
||||
|
||||
# Change filter |
||||
filters.open |
||||
filters.add_filter_by('Type', 'is', [type_bug.name]) |
||||
filters.expect_filter_count("2") |
||||
|
||||
# Save current filters |
||||
query_title.expect_changed |
||||
query_title.rename 'I am your Query' |
||||
calendar_page.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_create')) |
||||
|
||||
# The saved query appears in the side menu... |
||||
query_menu.expect_menu_entry 'I am your Query' |
||||
query_menu.expect_menu_entry saved_query.name |
||||
|
||||
# .. but not in the work packages module |
||||
work_package_page.visit! |
||||
query_menu.expect_menu_entry_not_visible 'I am your Query' |
||||
end |
||||
|
||||
it_behaves_like 'module specific query view management' do |
||||
let(:module_page) { calendar_page } |
||||
let(:default_name) { 'Unnamed calendar' } |
||||
end |
||||
end |
@ -0,0 +1,63 @@ |
||||
#-- 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. |
||||
#++ |
||||
|
||||
require 'support/pages/page' |
||||
|
||||
module Pages |
||||
class Calendar < ::Pages::Page |
||||
attr_reader :project, |
||||
:filters |
||||
|
||||
def initialize(project) |
||||
super() |
||||
|
||||
@project = project |
||||
@filters = ::Components::WorkPackages::Filters.new |
||||
end |
||||
|
||||
def path |
||||
project_calendar_path(project) |
||||
end |
||||
|
||||
def expect_title(title = 'Unnamed calendar') |
||||
expect(page).to have_selector '.editable-toolbar-title--fixed', text: title |
||||
end |
||||
|
||||
def expect_event(work_package, present: true) |
||||
expect(page).to have_conditional_selector(present, '.fc-event', text: work_package.subject) |
||||
end |
||||
|
||||
def open_split_view(work_package) |
||||
page |
||||
.find('.fc-event', text: work_package.subject) |
||||
.click |
||||
|
||||
::Pages::SplitWorkPackage.new(work_package, project) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue