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

round trip for creating a work package on ifc page

ulferts46da78f8c11f
diff --git a/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts b/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts
index 687e48795fd..5319259aa32 100644
--- a/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts
+++ b/frontend/src/app/components/modals/editor/macro-wp-button-modal/wp-button-macro.modal.ts
@@ -31,7 +31,6 @@ import {OpModalLocalsToken} from "core-components/op-modals/op-modal.service";
import {AfterViewInit, ChangeDetectorRef, Component, ElementRef, Inject, ViewChild} from "@angular/core";
import {OpModalLocalsMap} from "core-components/op-modals/op-modal.types";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
-import {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";
import {TypeResource} from "core-app/modules/hal/resources/type-resource";
import {CurrentProjectService} from "core-components/projects/current-project.service";
import {WorkPackageDmService} from "core-app/modules/hal/dm-services/work-package-dm.service";
diff --git a/frontend/src/app/components/op-context-menu/handlers/op-types-context-menu.directive.ts b/frontend/src/app/components/op-context-menu/handlers/op-types-context-menu.directive.ts
index b4fbc8f477a..20160d0a6c1 100644
--- a/frontend/src/app/components/op-context-menu/handlers/op-types-context-menu.directive.ts
+++ b/frontend/src/app/components/op-context-menu/handlers/op-types-context-menu.directive.ts
@@ -33,7 +33,6 @@ import {Directive, ElementRef, Input, Inject} from "@angular/core";
import {LinkHandling} from "core-app/modules/common/link-handling/link-handling";
import {OpContextMenuTrigger} from "core-components/op-context-menu/handlers/op-context-menu-trigger.directive";
import {TypeResource} from 'core-app/modules/hal/resources/type-resource';
-import {TypeDmService} from "core-app/modules/hal/dm-services/type-dm.service";
import {Highlighting} from 'core-app/components/wp-fast-table/builders/highlighting/highlighting.functions';
import {BrowserDetector} from "core-app/modules/common/browser/browser-detector.service";
import {WorkPackageCreateService} from 'core-components/wp-new/wp-create.service';
diff --git a/frontend/src/app/components/wp-copy/wp-copy.controller.ts b/frontend/src/app/components/wp-copy/wp-copy.controller.ts
index 63dd7a64660..d707c658e53 100644
--- a/frontend/src/app/components/wp-copy/wp-copy.controller.ts
+++ b/frontend/src/app/components/wp-copy/wp-copy.controller.ts
@@ -34,7 +34,6 @@ import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";
import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";
import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";
-import {ChangeDetectionStrategy} from "@angular/core";
import {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
diff --git a/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.html b/frontend/src/app/modules/ifc_models/bcf/list-container/bcf-list-container.component.html
similarity index 100%
rename from frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.html
rename to frontend/src/app/modules/ifc_models/bcf/list-container/bcf-list-container.component.html
diff --git a/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts b/frontend/src/app/modules/ifc_models/bcf/list-container/bcf-list-container.component.ts
similarity index 94%
rename from frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts
rename to frontend/src/app/modules/ifc_models/bcf/list-container/bcf-list-container.component.ts
index 3b63a2d74b4..2b9b09d00cf 100644
--- a/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts
+++ b/frontend/src/app/modules/ifc_models/bcf/list-container/bcf-list-container.component.ts
@@ -7,9 +7,9 @@ import { StateService } from '@uirouter/core';
import {GonService} from "core-app/modules/common/gon/gon.service";
@Component({
- templateUrl: './bcf-container.component.html'
+ templateUrl: './bcf-list-container.component.html'
})
-export class BCFContainerComponent {
+export class BCFListContainerComponent {
public queryProps:{ [key:string]:any };
public configuration:WorkPackageTableConfigurationObject = {
actionsColumnEnabled: false,
diff --git a/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.html b/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.html
new file mode 100644
index 00000000000..5c089af78ca
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.html
@@ -0,0 +1,24 @@
+<div
+ class="work-packages--details work-packages--new"
+ *ngIf="newWorkPackage"
+>
+ <edit-form [resource]="newWorkPackage"
+ [skippedFields]="['status', 'type']"
+ [inEditMode]="true"
+ (onSaved)="onSaved($event)">
+ <div class="work-packages--details-content -create-mode">
+ <div class="work-packages--new-details-header">
+ <wp-type-status [workPackage]="newWorkPackage"></wp-type-status>
+ </div>
+ <wp-single-view [workPackage]="newWorkPackage"
+ [showProject]="copying">
+ </wp-single-view>
+ </div>
+
+ <div class="work-packages--details-toolbar-container">
+ <wp-edit-actions-bar
+ (onCancel)="cancelAndBackToList()">
+ </wp-edit-actions-bar>
+ </div>
+ </edit-form>
+</div>
diff --git a/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.ts b/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.ts
new file mode 100644
index 00000000000..1fce3793aad
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/bcf/new-split/bcf-new-split.component.ts
@@ -0,0 +1,38 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2020 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 docs/COPYRIGHT.rdoc for more details.
+// ++
+
+import {WorkPackageCreateController} from 'core-components/wp-new/wp-create.controller';
+import {Component} from '@angular/core';
+
+@Component({
+ selector: 'bcf-new-split',
+ templateUrl: './bcf-new-split.component.html'
+})
+export class BCFNewSplitComponent extends WorkPackageCreateController {
+ public successState:string = 'bim.space.defaults';
+}
diff --git a/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts b/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts
index 94ccfc6b67e..56d6e1097cb 100644
--- a/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts
+++ b/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts
@@ -32,15 +32,17 @@ import {OpenprojectCommonModule} from "core-app/modules/common/openproject-commo
import {IFCViewerComponent} from './ifc-viewer/ifc-viewer.component';
import {IFC_ROUTES} from "core-app/modules/ifc_models/openproject-ifc-models.routes";
import {IFCViewerPageComponent} from "core-app/modules/ifc_models/pages/viewer/ifc-viewer-page.component";
-import {BCFContainerComponent} from "core-app/modules/ifc_models/bcf/container/bcf-container.component";
import {BimViewToggleDropdownDirective} from "core-app/modules/ifc_models/view-toggle/bim-view-toggle-dropdown.directive";
import {BimViewToggleComponent} from "core-app/modules/ifc_models/view-toggle/bim-view-toggle.component";
import {EmptyComponent} from "core-app/modules/ifc_models/empty/empty-component";
-import {BimViewService} from "core-app/modules/ifc_models/view-toggle/bim-view.service";
+import {OpenprojectFieldsModule} from "core-app/modules/fields/openproject-fields.module";
+import {BCFListContainerComponent} from "core-app/modules/ifc_models/bcf/list-container/bcf-list-container.component";
+import {BCFNewSplitComponent} from "core-app/modules/ifc_models/bcf/new-split/bcf-new-split.component";
@NgModule({
imports: [
OpenprojectCommonModule,
+ OpenprojectFieldsModule,
OpenprojectWorkPackagesModule,
UIRouterModule.forChild({
states: IFC_ROUTES
@@ -52,12 +54,13 @@ import {BimViewService} from "core-app/modules/ifc_models/view-toggle/bim-view.s
// Regions of pages
EmptyComponent,
- BCFContainerComponent,
// View selector
BimViewToggleComponent,
BimViewToggleDropdownDirective,
+ BCFListContainerComponent,
+ BCFNewSplitComponent,
IFCViewerComponent
],
exports: [
diff --git a/frontend/src/app/modules/ifc_models/openproject-ifc-models.routes.ts b/frontend/src/app/modules/ifc_models/openproject-ifc-models.routes.ts
index 95d08c97472..880c50a0348 100644
--- a/frontend/src/app/modules/ifc_models/openproject-ifc-models.routes.ts
+++ b/frontend/src/app/modules/ifc_models/openproject-ifc-models.routes.ts
@@ -27,10 +27,12 @@
// ++
import {Ng2StateDeclaration, UIRouter} from '@uirouter/angular';
import {IFCViewerPageComponent} from "core-app/modules/ifc_models/pages/viewer/ifc-viewer-page.component";
-import {BCFContainerComponent} from "core-app/modules/ifc_models/bcf/container/bcf-container.component";
+import {BCFListContainerComponent} from "core-app/modules/ifc_models/bcf/list-container/bcf-list-container.component";
import {IFCViewerComponent} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.component";
import {WorkPackagesBaseComponent} from "core-app/modules/work_packages/routing/wp-base/wp--base.component";
import {EmptyComponent} from "core-app/modules/ifc_models/empty/empty-component";
+import {WorkPackageNewSplitViewComponent} from "core-components/wp-new/wp-new-split-view.component";
+import {BCFNewSplitComponent} from "core-app/modules/ifc_models/bcf/new-split/bcf-new-split.component";
export const IFC_ROUTES:Ng2StateDeclaration[] = [
{
@@ -54,7 +56,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
viewRoute: 'bim.space.defaults',
},
views: {
- list: { component: BCFContainerComponent }
+ list: { component: BCFListContainerComponent }
}
},
{
@@ -66,7 +68,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
},
views: {
viewer: { component: IFCViewerComponent },
- list: { component: BCFContainerComponent }
+ list: { component: BCFListContainerComponent }
}
},
{
@@ -82,6 +84,18 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
'list@^.^': { component: EmptyComponent }
}
},
+ {
+ name: 'bim.space.defaults.new',
+ url: '/new?{type:[0-9]+}',
+ component: IFCViewerPageComponent,
+ reloadOnSearch: false,
+ views: {
+ viewer: { component: IFCViewerComponent },
+ // Retarget and by that override the grandparent views
+ // https://ui-router.github.io/guide/views#relative-parent-state
+ 'list@^.^': { component: BCFNewSplitComponent }
+ }
+ },
{
name: 'bim.space.show',
url: '/{model_id:[0-9]+}',
@@ -91,7 +105,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
},
views: {
viewer: { component: IFCViewerComponent },
- list: { component: BCFContainerComponent }
+ list: { component: BCFListContainerComponent }
}
},
{
diff --git a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html
index aadbdcbf34f..c716f1dd30c 100644
--- a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html
+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html
@@ -5,9 +5,18 @@
</h2>
</div>
<ul class="toolbar-items">
+
+ <li class="toolbar-item">
+ <wp-create-button
+ [allowed]="createAllowed"
+ [stateName]="createState">
+ </wp-create-button>
+ </li>
+
<li class="toolbar-item">
<bim-view-toggle-button></bim-view-toggle-button>
</li>
+
<li class="toolbar-item"
*ngIf="manageAllowed">
<a class="button"
@@ -18,9 +27,11 @@
aria-hidden="true"></span>
</a>
</li>
+
<li class="toolbar-item hidden-for-mobile">
<zen-mode-toggle-button></zen-mode-toggle-button>
</li>
+
</ul>
</div>
</div>
diff --git a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts
index f12cf99c748..96de7fcf058 100644
--- a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts
+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts
@@ -1,7 +1,8 @@
import {Component, Injector, HostBinding, ChangeDetectionStrategy} from "@angular/core";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
-import {GonService} from "core-app/modules/common/gon/gon.service";
import {WorkPackagesViewBase} from "core-app/modules/work_packages/routing/wp-view-base/work-packages-view.base";
+import {GonService} from "core-app/modules/common/gon/gon.service";
+import {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";
@Component({
templateUrl: './ifc-viewer-page.component.html',
@@ -19,6 +20,7 @@ export class IFCViewerPageComponent extends WorkPackagesViewBase {
constructor(readonly paths:PathHelperService,
readonly gon:GonService,
+ readonly wpCreate:WorkPackageCreateService,
readonly injector:Injector) {
super(injector);
}
@@ -50,6 +52,15 @@ export class IFCViewerPageComponent extends WorkPackagesViewBase {
return this.gonIFC.permissions.manage;
}
+ public get createState() {
+ return 'bim.space.defaults.new';
+ }
+
+ public get createAllowed() {
+ // TODO: get info from query space to see if creation is allowed
+ return true;
+ }
+
private get gonIFC() {
return (this.gon.get('ifc_models') as any);
}
diff --git a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
index 21f2a197afa..713f8e986e9 100644
--- a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
@@ -164,6 +164,7 @@ import {HalResource} from "core-app/modules/hal/resources/hal-resource";
import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";
import {WorkPackageSingleCardComponent} from "core-components/wp-card-view/wp-single-card/wp-single-card.component";
import { TimeEntryChangeset } from 'core-app/components/time-entries/time-entry-changeset';
+import {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";
@NgModule({
@@ -471,6 +472,12 @@ import { TimeEntryChangeset } from 'core-app/components/time-entries/time-entry-
// Modals
WpTableConfigurationModalComponent,
WpTableConfigurationFiltersTab,
+
+ // Needed so that e.g. IFC can access it.
+ WorkPackageCreateButtonComponent,
+ WorkPackageTypeStatusComponent,
+ WorkPackageEditActionsBarComponent,
+ WorkPackageSingleViewComponent
]
})
export class OpenprojectWorkPackagesModule {
diff --git a/modules/bim/spec/features/bcf_api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb
similarity index 100%
rename from modules/bim/spec/features/bcf_api_authorization_spec.rb
rename to modules/bim/spec/features/bcf/api_authorization_spec.rb
diff --git a/modules/bim/spec/features/bcf/create_spec.rb b/modules/bim/spec/features/bcf/create_spec.rb
new file mode 100644
index 00000000000..78f783876ea
--- /dev/null
+++ b/modules/bim/spec/features/bcf/create_spec.rb
@@ -0,0 +1,77 @@
+require 'spec_helper'
+
+require_relative '../../support/pages/ifc_models/show_default'
+
+describe 'Create BCF', type: :feature, js: true, with_mail: false do
+ let(:project) { FactoryBot.create :project, types: [type] }
+ let(:index_page) { Pages::IfcModels::ShowDefault.new(project) }
+ let(:permissions) { %i[view_ifc_models manage_ifc_models add_work_packages view_work_packages] }
+ let!(:status) { FactoryBot.create(:default_status) }
+ let!(:priority) { FactoryBot.create :priority, is_default: true }
+
+ let(:user) do
+ FactoryBot.create :user,
+ member_in_project: project,
+ member_with_permissions: permissions
+ end
+
+ let!(:model) do
+ FactoryBot.create(:ifc_model_converted,
+ project: project,
+ uploader: user)
+ end
+ let(:type) { FactoryBot.create(:type) }
+
+ before do
+ login_as(user)
+ index_page.visit!
+ end
+
+ context 'with all permissions' do
+ it 'can create a new bcf work package' do
+ create_page = index_page.create_wp_by_button(type)
+
+ create_page.expect_current_path
+
+ create_page.subject_field.set(subject)
+ create_page.save!
+
+ # TODO: adapt notification message
+ index_page.expect_and_dismiss_notification(
+ message: 'Successful creation. Click here to open this work package in fullscreen view.'
+ )
+
+ work_package = WorkPackage.last
+
+ index_page.expect_work_package_listed(work_package)
+
+
+ #index_page.model_listed true, model.title
+ #index_page.add_model_allowed true
+ #index_page.edit_model_allowed model.title, true
+ #index_page.delete_model_allowed model.title, true
+
+ #index_page.edit_model model.title, 'My super cool new name'
+ #index_page.delete_model 'My super cool new name'
+ end
+ end
+
+ context 'without create permission' do
+ let(:permissions) { %i[view_ifc_models manage_ifc_models] }
+
+ #it 'I can see, but not edit models' do
+ # index_page.model_listed true, model.title
+ # index_page.add_model_allowed false
+ # index_page.edit_model_allowed model.title, false
+ # index_page.delete_model_allowed model.title, false
+ #end
+
+ #it 'I can see single models and the defaults' do
+ # index_page.model_listed true, model.title
+ # index_page.show_model model
+
+ # index_page.model_listed true, model.title
+ # index_page.show_defaults
+ #end
+ end
+end
diff --git a/modules/bim/spec/features/bcf_export_spec.rb b/modules/bim/spec/features/bcf/export_spec.rb
similarity index 98%
rename from modules/bim/spec/features/bcf_export_spec.rb
rename to modules/bim/spec/features/bcf/export_spec.rb
index 9ba5c18c3c6..67e7960f719 100644
--- a/modules/bim/spec/features/bcf_export_spec.rb
+++ b/modules/bim/spec/features/bcf/export_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-describe 'work package export', type: :feature, js: true do
+describe 'bcf export', type: :feature, js: true do
let(:status) { FactoryBot.create(:status, name: 'New', is_default: true) }
let(:closed_status) { FactoryBot.create(:closed_status, name: 'Closed') }
let(:project) { FactoryBot.create :project, enabled_module_names: [:bim, :work_package_tracking] }
diff --git a/modules/bim/spec/support/pages/bcf/create_split.rb b/modules/bim/spec/support/pages/bcf/create_split.rb
new file mode 100644
index 00000000000..16fc9e70b2d
--- /dev/null
+++ b/modules/bim/spec/support/pages/bcf/create_split.rb
@@ -0,0 +1,71 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+require 'support/pages/page'
+require 'support/pages/work_packages/abstract_work_package_create'
+
+module Pages
+ module BCF
+ class CreateSplit < ::Pages::AbstractWorkPackageCreate
+ attr_accessor :project,
+ :model_id,
+ :type_id
+
+ def initialize(project, model_id: nil, type_id: nil)
+ super(project: project)
+ self.model_id = model_id
+ self.type_id = type_id
+ end
+
+ def path
+ path = if default?
+ defaults_ifc_models_project_ifc_models_path(project)
+ else
+ ifc_models_project_ifc_model(project, id: model_id)
+ end + '/new'
+
+ query = if type_id
+ "?type=#{type_id}"
+ end
+
+ path + query
+ end
+
+ def expect_current_path
+ expect(page)
+ .to have_current_path(path)
+ end
+
+ private
+
+ def default?
+ model_id.nil?
+ end
+ end
+ end
+end
diff --git a/modules/bim/spec/support/pages/ifc_models/index.rb b/modules/bim/spec/support/pages/ifc_models/index.rb
index 0a675d1d05a..fc03ffbd384 100644
--- a/modules/bim/spec/support/pages/ifc_models/index.rb
+++ b/modules/bim/spec/support/pages/ifc_models/index.rb
@@ -27,6 +27,7 @@
#++
require 'support/pages/page'
+require 'support/pages/work_packages/concerns/work_package_by_button_creator'
module Pages
module IfcModels
diff --git a/modules/bim/spec/support/pages/ifc_models/show_default.rb b/modules/bim/spec/support/pages/ifc_models/show_default.rb
index 5c13c8f794a..e2fca8a953a 100644
--- a/modules/bim/spec/support/pages/ifc_models/show_default.rb
+++ b/modules/bim/spec/support/pages/ifc_models/show_default.rb
@@ -27,10 +27,13 @@
#++
require 'support/pages/page'
+require_relative '../bcf/create_split'
module Pages
module IfcModels
- class ShowDefault < ::Pages::Page
+ class ShowDefault < ::Pages::WorkPackageCards
+ include ::Pages::WorkPackages::Concerns::WorkPackageByButtonCreator
+
attr_accessor :project
def initialize(project)
@@ -94,6 +97,14 @@ module Pages
def toolbar_items
['Manage models']
end
+
+ def create_page_class_instance(type)
+ create_page_class.new(project, type_id: type.id)
+ end
+
+ def create_page_class
+ Pages::BCF::CreateSplit
+ end
end
end
end
diff --git a/modules/meeting/lib/open_project/meeting/patches/textile_converter_patch.rb b/modules/meeting/lib/open_project/meeting/patches/textile_converter_patch.rb
index 8ecf9309f2f..7d818b5da6a 100644
--- a/modules/meeting/lib/open_project/meeting/patches/textile_converter_patch.rb
+++ b/modules/meeting/lib/open_project/meeting/patches/textile_converter_patch.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/features/work_packages/new/attributes_from_filter_spec.rb b/spec/features/work_packages/new/attributes_from_filter_spec.rb
index 788037c383f..b38c9eb0cfd 100644
--- a/spec/features/work_packages/new/attributes_from_filter_spec.rb
+++ b/spec/features/work_packages/new/attributes_from_filter_spec.rb
@@ -92,7 +92,7 @@ RSpec.feature 'Work package create uses attributes from filters', js: true, sele
end
it 'allows to save with a single value (Regression test #27833)' do
- split_page = wp_table.create_wp_split_screen type_task
+ split_page = wp_table.create_wp_by_button type_task
subject = split_page.edit_field(:subject)
subject.expect_active!
diff --git a/spec/features/work_packages/new/work_package_default_description_spec.rb b/spec/features/work_packages/new/work_package_default_description_spec.rb
index 8297b24caf2..6776009ef23 100644
--- a/spec/features/work_packages/new/work_package_default_description_spec.rb
+++ b/spec/features/work_packages/new/work_package_default_description_spec.rb
@@ -83,7 +83,7 @@ describe 'new work package', js: true, with_mail: false do
it 'shows the template after selection of project and type' do
wp_table.visit!
- wp_table.create_wp_split_screen type_feature
+ wp_table.create_wp_by_button type_feature
wp_page.expect_fully_loaded
diff --git a/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb b/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb
index 3f05e23f00d..7f6122fa1a0 100644
--- a/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb
+++ b/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb
@@ -36,7 +36,7 @@ describe 'Parallel work package creation spec', js: true do
subject_field.set_value subject
# Create in split screen
- split = wp_table.create_wp_split_screen type
+ split = wp_table.create_wp_by_button type
description_field = TextEditorField.new split, 'description'
description_field.expect_active!
description_field.set_value description
diff --git a/spec/features/work_packages/table/queries/me_filter_spec.rb b/spec/features/work_packages/table/queries/me_filter_spec.rb
index 4e47258bc0e..923659062df 100644
--- a/spec/features/work_packages/table/queries/me_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/me_filter_spec.rb
@@ -106,7 +106,7 @@ describe 'filter me value', js: true do
filters.expect_filter_by('Assignee', 'is', 'me')
# Expect new work packages receive assignee
- split_screen = wp_table.create_wp_split_screen wp_user.type
+ split_screen = wp_table.create_wp_by_button wp_user.type
subject = split_screen.edit_field :subject
subject.set_value 'foobar'
subject.submit_by_enter
diff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rb
index b10c4dd33be..f9263a695b0 100644
--- a/spec/support/pages/work_packages/abstract_work_package.rb
+++ b/spec/support/pages/work_packages/abstract_work_package.rb
@@ -30,14 +30,11 @@ require 'support/pages/page'
module Pages
class AbstractWorkPackage < Page
- attr_reader :project, :work_package, :type_field_selector, :subject_field_selector
+ attr_reader :project, :work_package
def initialize(work_package, project = nil)
@work_package = work_package
@project = project
-
- @type_field_selector = '.inline-edit--container.type'
- @subject_field_selector = '.inline-edit--container.subject'
end
def visit_tab!(tab)
@@ -273,12 +270,12 @@ module Pages
end
def select_type(type)
- find(@type_field_selector + ' option', text: type.name.upcase).select_option
+ find('.inline-edit--container.type option', text: type.name.upcase).select_option
end
def subject_field
- expect(page).to have_selector(@subject_field_selector + ' input', wait: 10)
- find(@subject_field_selector + ' input')
+ expect(page).to have_selector('.inline-edit--container.subject input', wait: 10)
+ find('.inline-edit--container.subject input')
end
private
diff --git a/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb b/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb
new file mode 100644
index 00000000000..7eb88d053fe
--- /dev/null
+++ b/spec/support/pages/work_packages/concerns/work_package_by_button_creator.rb
@@ -0,0 +1,71 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+module Pages
+ module WorkPackages
+ module Concerns
+ module WorkPackageByButtonCreator
+ def create_wp_by_button(type)
+ click_wp_create_button
+
+ find('#types-context-menu .menu-item', text: type.name.upcase, wait: 10).click
+
+ create_page_class_instance(type)
+ end
+
+ def click_wp_create_button
+ find('.add-work-package:not([disabled])', text: 'Create').click
+ end
+
+ def expect_type_available_for_create(type)
+ click_wp_create_button
+
+ expect(page)
+ .to have_selector('#types-context-menu .menu-item', text: type.name.upcase)
+ end
+
+ def expect_type_not_available_for_create(type)
+ click_wp_create_button
+
+ expect(page)
+ .to have_no_selector('#types-context-menu .menu-item', text: type.name.upcase)
+ end
+
+ private
+
+ def create_page_class_instance(_type)
+ create_page_class.new(project)
+ end
+
+ def create_page_class
+ raise NotImplementedError
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb
index acc0201b212..aecafd165c2 100644
--- a/spec/support/pages/work_packages/work_packages_table.rb
+++ b/spec/support/pages/work_packages/work_packages_table.rb
@@ -27,9 +27,12 @@
#++
require 'support/pages/page'
+require_relative 'concerns/work_package_by_button_creator'
module Pages
class WorkPackagesTable < Page
+ include ::Pages::WorkPackages::Concerns::WorkPackageByButtonCreator
+
attr_reader :project
def initialize(project = nil)
@@ -135,32 +138,6 @@ module Pages
expect(container).to have_selector('.wp-inline-create-row', wait: 10)
end
- def create_wp_split_screen(type)
- click_wp_create_button
-
- find('#types-context-menu .menu-item', text: type.name.upcase, wait: 10).click
-
- SplitWorkPackageCreate.new(project: project)
- end
-
- def click_wp_create_button
- find('.add-work-package:not([disabled])', text: 'Create').click
- end
-
- def expect_type_available_for_create(type)
- click_wp_create_button
-
- expect(page)
- .to have_selector('#types-context-menu .menu-item', text: type.name.upcase)
- end
-
- def expect_type_not_available_for_create(type)
- click_wp_create_button
-
- expect(page)
- .to have_no_selector('#types-context-menu .menu-item', text: type.name.upcase)
- end
-
def open_split_view(work_package)
split_page = SplitWorkPackage.new(work_package, project)
@@ -311,5 +288,9 @@ module Pages
filter_container['id'].gsub('filter_', '')
end
end
+
+ def create_page_class
+ SplitWorkPackageCreate
+ end
end
end