Merge pull request #8071 from opf/bim/feature/create_bcf
Create work packages on IFC model page [ci skip]pull/8102/head
commit
254eddb354
@ -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> |
@ -0,0 +1,124 @@ |
||||
require 'spec_helper' |
||||
|
||||
require_relative '../../support/pages/ifc_models/show_default' |
||||
|
||||
|
||||
describe 'Create BCF', type: :feature, js: true, with_mail: false do |
||||
let(:project) do |
||||
FactoryBot.create(:project, types: [type, type_with_cf], work_package_custom_fields: [integer_cf]) |
||||
end |
||||
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) } |
||||
let(:type_with_cf) do |
||||
FactoryBot.create(:type, custom_fields: [integer_cf]) |
||||
end |
||||
let(:integer_cf) do |
||||
FactoryBot.create(:int_wp_custom_field) |
||||
end |
||||
|
||||
shared_examples 'bcf details creation' do |
||||
it 'can create a new bcf work package' do |
||||
create_page = index_page.create_wp_by_button(type) |
||||
create_page.view_route = view_route |
||||
|
||||
create_page.expect_current_path |
||||
|
||||
create_page.subject_field.set(subject) |
||||
|
||||
# switch the type |
||||
type_field = create_page.edit_field(:type) |
||||
type_field.activate! |
||||
type_field.set_value type_with_cf.name |
||||
|
||||
cf_field = create_page.edit_field(:"customField#{integer_cf.id}") |
||||
cf_field.set_value(815) |
||||
|
||||
create_page.save! |
||||
|
||||
index_page.expect_and_dismiss_notification( |
||||
message: 'Successful creation. Click here to open this work package in fullscreen view.' |
||||
) |
||||
|
||||
work_package = WorkPackage.last |
||||
split_page = ::Pages::SplitWorkPackage.new(work_package, project) |
||||
split_page.ensure_page_loaded |
||||
split_page.expect_subject |
||||
|
||||
split_page.close |
||||
split_page.expect_closed |
||||
|
||||
expect(page).to have_current_path /bcf\/#{Regexp.escape(view_route)}$/, ignore_query: true |
||||
end |
||||
end |
||||
|
||||
before do |
||||
login_as(user) |
||||
end |
||||
|
||||
context 'with all permissions' do |
||||
context 'on the split page' do |
||||
let(:view_route) { 'split' } |
||||
before do |
||||
index_page.visit! |
||||
end |
||||
|
||||
it_behaves_like 'bcf details creation' |
||||
end |
||||
|
||||
context 'on the split page switching to list' do |
||||
let(:view_route) { 'list' } |
||||
before do |
||||
index_page.visit! |
||||
index_page.switch_view 'List' |
||||
expect(page).to have_current_path /\/bcf\/list$/, ignore_query: true |
||||
end |
||||
|
||||
it_behaves_like 'bcf details creation' |
||||
end |
||||
|
||||
context 'starting on the list page' do |
||||
let(:view_route) { 'list' } |
||||
before do |
||||
visit bcf_project_frontend_path(project, "list") |
||||
expect(page).to have_current_path /\/bcf\/list$/, ignore_query: true |
||||
end |
||||
|
||||
it_behaves_like 'bcf details creation' |
||||
end |
||||
|
||||
context 'starting on the details page of an existing work package' do |
||||
let(:work_package) { FactoryBot.create :work_package, project: project } |
||||
let(:view_route) { 'split' } |
||||
before do |
||||
visit bcf_project_frontend_path(project, "split/details/#{work_package.id}") |
||||
expect(page).to have_current_path /\/bcf\/split\/details/, ignore_query: true |
||||
end |
||||
|
||||
it_behaves_like 'bcf details creation' |
||||
end |
||||
end |
||||
|
||||
context 'without create work package permission' do |
||||
let(:permissions) { %i[view_ifc_models manage_ifc_models view_work_packages] } |
||||
|
||||
it 'has the create button disabled' do |
||||
index_page.visit! |
||||
index_page.expect_wp_create_button_disabled |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,67 @@ |
||||
#-- 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, |
||||
:view_route |
||||
|
||||
def initialize(project:, model_id: nil, type_id: nil) |
||||
super(project: project) |
||||
self.model_id = model_id |
||||
self.type_id = type_id |
||||
self.view_route = :split |
||||
end |
||||
|
||||
def path |
||||
bcf_project_frontend_path(project, "#{view_route}/create_new") |
||||
end |
||||
|
||||
def expect_current_path |
||||
expect(page) |
||||
.to have_current_path(path, ignore_query: true) |
||||
end |
||||
|
||||
def container |
||||
find("wp-new-split-view") |
||||
end |
||||
|
||||
private |
||||
|
||||
def default? |
||||
model_id.nil? |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,76 @@ |
||||
#-- 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_wp_create_button_disabled |
||||
expect(page) |
||||
.to have_selector('.add-work-package[disabled]', text: 'Create') |
||||
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: project) |
||||
end |
||||
|
||||
def create_page_class |
||||
raise NotImplementedError |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue