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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix aborting bcf creation
ulfertsc472aab4cbb0
diff --git a/frontend/src/app/components/wp-copy/wp-copy.controller.ts b/frontend/src/app/components/wp-copy/wp-copy.controller.tsindex d707c658e53..eca9fb22314 100644--- a/frontend/src/app/components/wp-copy/wp-copy.controller.ts+++ b/frontend/src/app/components/wp-copy/wp-copy.controller.ts@@ -28,7 +28,7 @@import {take} from 'rxjs/operators';import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';-import {WorkPackageCreateController} from 'core-components/wp-new/wp-create.controller';+import {WorkPackageCreateComponent} from 'core-components/wp-new/wp-create.component';import {WorkPackageRelationsService} from "core-components/wp-relations/wp-relations.service";import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";@@ -37,7 +37,7 @@ import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changesimport {WorkPackageCreateService} from "core-components/wp-new/wp-create.service";import {InjectField} from "core-app/helpers/angular/inject-field.decorator";-export class WorkPackageCopyController extends WorkPackageCreateController {+export class WorkPackageCopyController extends WorkPackageCreateComponent {private __initialized_at:Number;private copiedWorkPackageId:string;diff --git a/frontend/src/app/components/wp-new/wp-create.controller.ts b/frontend/src/app/components/wp-new/wp-create.component.tssimilarity index 93%rename from frontend/src/app/components/wp-new/wp-create.controller.tsrename to frontend/src/app/components/wp-new/wp-create.component.tsindex d4d49d5df7e..deb26267d41 100644--- a/frontend/src/app/components/wp-new/wp-create.controller.ts+++ b/frontend/src/app/components/wp-new/wp-create.component.ts@@ -26,7 +26,7 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {ChangeDetectorRef, Injectable, Injector, OnDestroy, OnInit, ViewChild} from '@angular/core';+import {ChangeDetectorRef, Injector, OnDestroy, OnInit, ViewChild} from '@angular/core';import {StateService, Transition} from '@uirouter/core';import {PathHelperService} from 'core-app/modules/common/path-helper/path-helper.service';import {componentDestroyed, untilComponentDestroyed} from 'ng2-rx-componentdestroyed';@@ -34,24 +34,20 @@ import {States} from '../states.service';import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';import {RootResource} from 'core-app/modules/hal/resources/root-resource';import {WorkPackageCacheService} from '../work-packages/work-package-cache.service';-import {HalResourceNotificationService} from "core-app/modules/hal/services/hal-resource-notification.service";import {WorkPackageCreateService} from './wp-create.service';import {takeUntil} from 'rxjs/operators';import {RootDmService} from 'core-app/modules/hal/dm-services/root-dm.service';import {OpTitleService} from 'core-components/html/op-title.service';import {I18nService} from "core-app/modules/common/i18n/i18n.service";-import {CurrentUserService} from "core-app/components/user/current-user.service";import {WorkPackageViewFiltersService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-filters.service";import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";import {WorkPackageViewFocusService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-focus.service";-import {HalResource} from "core-app/modules/hal/resources/hal-resource";import {EditFormComponent} from "core-app/modules/fields/edit/edit-form/edit-form.component";import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";--@Injectable()-export class WorkPackageCreateController implements OnInit, OnDestroy {+export abstract class WorkPackageCreateComponent implements OnInit, OnDestroy {public successState:string;+ public cancelState:string = 'work-packages.list';public newWorkPackage:WorkPackageResource;public parentWorkPackage:WorkPackageResource;public change:WorkPackageChangeset;@@ -86,6 +82,36 @@ export class WorkPackageCreateController implements OnInit, OnDestroy {public ngOnInit() {this.closeEditFormWhenNewWorkPackageSaved();+ this.showForm();+ }++ public ngOnDestroy() {+ // Nothing to do+ }++ public switchToFullscreen() {+ this.$state.go('work-packages.new', this.$state.params);+ }++ public onSaved(params:{ savedResource:WorkPackageResource, isInitial:boolean }) {+ let {savedResource, isInitial} = params;++ // Shouldn't this always be true in create controller?+ // Close all edit fields when saving+ if (isInitial && this.editForm && this.editForm.editMode) {+ this.editForm.stop();+ }++ if (this.successState) {+ this.$state.go(this.successState, {workPackageId: savedResource.id})+ .then(() => {+ this.wpViewFocus.updateFocus(savedResource.id!);+ this.notificationService.showSave(savedResource, isInitial);+ });+ }+ }++ protected showForm() {this.createdWorkPackage().then((changeset:WorkPackageChangeset) => {@@ -128,39 +154,13 @@ export class WorkPackageCreateController implements OnInit, OnDestroy {});}- public ngOnDestroy() {- // Nothing to do- }-- public switchToFullscreen() {- this.$state.go('work-packages.new', this.$state.params);- }-- public onSaved(params:{ savedResource:WorkPackageResource, isInitial:boolean }) {- let {savedResource, isInitial} = params;-- // Shouldn't this always be true in create controller?- // Close all edit fields when saving- if (isInitial && this.editForm && this.editForm.editMode) {- this.editForm.stop();- }-- if (this.successState) {- this.$state.go(this.successState, {workPackageId: savedResource.id})- .then(() => {- this.wpViewFocus.updateFocus(savedResource.id!);- this.notificationService.showSave(savedResource, isInitial);- });- }- }-protected setTitle() {this.titleService.setFirstPart(this.I18n.t('js.work_packages.create.title'));}public cancelAndBackToList() {this.wpCreate.cancelCreation();- this.$state.go('work-packages.list', this.$state.params);+ this.$state.go(this.cancelState, this.$state.params);}protected createdWorkPackage() {diff --git a/frontend/src/app/components/wp-new/wp-new-full-view.component.ts b/frontend/src/app/components/wp-new/wp-new-full-view.component.tsindex be6a83989f0..f0a75fa54be 100644--- a/frontend/src/app/components/wp-new/wp-new-full-view.component.ts+++ b/frontend/src/app/components/wp-new/wp-new-full-view.component.ts@@ -26,7 +26,7 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {WorkPackageCreateController} from 'core-components/wp-new/wp-create.controller';+import {WorkPackageCreateComponent} from 'core-components/wp-new/wp-create.component';import {Component} from '@angular/core';@Component({@@ -34,6 +34,6 @@ import {Component} from '@angular/core';host: { 'class': 'work-packages-page--ui-view' },templateUrl: './wp-new-full-view.html'})-export class WorkPackageNewFullViewComponent extends WorkPackageCreateController {+export class WorkPackageNewFullViewComponent extends WorkPackageCreateComponent {public successState:string = 'work-packages.show';}diff --git a/frontend/src/app/components/wp-new/wp-new-split-view.component.ts b/frontend/src/app/components/wp-new/wp-new-split-view.component.tsindex 5c421e53488..e6c543ba21a 100644--- a/frontend/src/app/components/wp-new/wp-new-split-view.component.ts+++ b/frontend/src/app/components/wp-new/wp-new-split-view.component.ts@@ -26,13 +26,13 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {WorkPackageCreateController} from 'core-components/wp-new/wp-create.controller';+import {WorkPackageCreateComponent} from 'core-components/wp-new/wp-create.component';import {Component} from '@angular/core';@Component({selector: 'wp-new-split-view',templateUrl: './wp-new-split-view.html'})-export class WorkPackageNewSplitViewComponent extends WorkPackageCreateController {+export class WorkPackageNewSplitViewComponent extends WorkPackageCreateComponent {public successState:string = 'work-packages.list.details';}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.tsindex 1fce3793aad..98ac3af32fa 100644--- 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@@ -26,13 +26,24 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {WorkPackageCreateController} from 'core-components/wp-new/wp-create.controller';+import {WorkPackageCreateComponent} from 'core-components/wp-new/wp-create.component';import {Component} from '@angular/core';+import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";+import {InjectField} from "core-app/helpers/angular/inject-field.decorator";+import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.service";@Component({selector: 'bcf-new-split',templateUrl: './bcf-new-split.component.html'})-export class BCFNewSplitComponent extends WorkPackageCreateController {+export class BCFNewSplitComponent extends WorkPackageCreateComponent {public successState:string = 'bim.space.defaults';+ public cancelState:string = 'bim.space.defaults';++ @InjectField()+ readonly viewer:IFCViewerService;++ public onSaved(params:{ savedResource:WorkPackageResource, isInitial:boolean }) {+ super.onSaved(params);+ }}diff --git a/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.component.ts b/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.component.tsindex 5353206dc6e..5a2dd220613 100644--- a/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.component.ts+++ b/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.component.ts@@ -26,12 +26,10 @@// See docs/COPYRIGHT.rdoc for more details.// ++-/// <reference path="../xeokit/xeokit.d.ts" />+import {Component, ElementRef, OnInit, OnDestroy, ChangeDetectionStrategy} from '@angular/core';-import {ChangeDetectionStrategy, Component, ElementRef, OnDestroy, OnInit} from '@angular/core';--import {XeokitServer} from "../xeokit/xeokit-server";import {GonService} from "core-app/modules/common/gon/gon.service";+import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.service";@Component({selector: 'ifc-viewer',@@ -49,46 +47,26 @@ export class IFCViewerComponent implements OnInit, OnDestroy {private viewerUI:any;constructor(private Gon:GonService,- private elementRef:ElementRef) {+ private elementRef:ElementRef,+ private ifcViewer:IFCViewerService) {}ngOnInit():void {const element = jQuery(this.elementRef.nativeElement as HTMLElement);- import('@xeokit/xeokit-viewer/dist/main').then((XeokitViewerModule:any) => {- let server = new XeokitServer();- this.viewerUI = new XeokitViewerModule.BIMViewer(server, {+ this.ifcViewer.newViewer(+ {canvasElement: element.find(".ifc-model-viewer--model-canvas")[0], // WebGL canvasexplorerElement: jQuery(".ifc-model-viewer--tree-panel")[0], // Left paneltoolbarElement: element.find(".ifc-model-viewer--toolbar-container")[0], // ToolbarnavCubeCanvasElement: element.find(".ifc-model-viewer--nav-cube-canvas")[0],sectionPlanesOverviewCanvasElement: element.find(".ifc-model-viewer--section-planes-overview-canvas")[0]- });-- this.viewerUI.on("queryPicked", (event:any) => {- const entity = event.entity; // Entity- const metaObject = event.metaObject; // MetaObject- alert(`Query result:\n\nObject ID = ${entity.id}\nIFC type = "${metaObject.type}"`);- });-- this.viewerUI.loadProject(this.Gon.get('ifc_models', 'projects') as any [0]["id"]);- });+ },+ this.Gon.get('ifc_models', 'projects') as any[]+ );}ngOnDestroy():void {- if (!this.viewerUI) {- return;- }-- this.viewerUI._bcfViewpointsPlugin.destroy();- this.viewerUI._canvasContextMenu.destroy();- this.viewerUI._objectContextMenu.destroy();-- while (this.viewerUI.viewer._plugins.length > 0) {- const plugin = this.viewerUI.viewer._plugins[0];- plugin.destroy();- }-- this.viewerUI.viewer.scene.destroy();+ this.ifcViewer.destroy();}}diff --git a/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.service.ts b/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.service.tsnew file mode 100644index 00000000000..1def2d61b32--- /dev/null+++ b/frontend/src/app/modules/ifc_models/ifc-viewer/ifc-viewer.service.ts@@ -0,0 +1,59 @@+import { Injectable } from '@angular/core';+import {XeokitServer} from "core-app/modules/ifc_models/xeokit/xeokit-server";++export interface XeokitElements {+ canvasElement:HTMLElement;+ explorerElement:HTMLElement;+ toolbarElement:HTMLElement;+ navCubeCanvasElement:HTMLElement;+ sectionPlanesOverviewCanvasElement:HTMLElement;+}++export interface BCFCreationOptions {+ spacesVisible:boolean;+ spaceBoundariesVisible:boolean;+ openingsVisible:boolean;+}++@Injectable()+export class IFCViewerService {+ private viewer:any;++ public newViewer(elements:XeokitElements, projects:any[]) {+ import('@xeokit/xeokit-viewer/dist/main').then((XeokitViewerModule:any) => {+ let server = new XeokitServer();+ let viewerUI = new XeokitViewerModule.BIMViewer(server, elements);++ viewerUI.on("queryPicked", (event:any) => {+ const entity = event.entity; // Entity+ const metaObject = event.metaObject; // MetaObject+ alert(`Query result:\n\nObject ID = ${entity.id}\nIFC type = "${metaObject.type}"`);+ });++ viewerUI.loadProject(projects[0]["id"]);++ this.viewer = viewerUI;+ });+ }++ public destroy() {+ if (!this.viewer) {+ return;+ }++ this.viewer._bcfViewpointsPlugin.destroy();+ this.viewer._canvasContextMenu.destroy();+ this.viewer._objectContextMenu.destroy();++ while (this.viewer.viewer._plugins.length > 0) {+ const plugin = this.viewer.viewer._plugins[0];+ plugin.destroy();+ }++ this.viewer.viewer.scene.destroy();+ }++ public saveBCFViewpoint(options:BCFCreationOptions):JSON {+ return this.viewer.saveBCFViewpoint(options);+ }+}\ No newline at end of filediff --git a/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts b/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.tsindex 56d6e1097cb..1b887d68033 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@@ -38,6 +38,7 @@ import {EmptyComponent} from "core-app/modules/ifc_models/empty/empty-component"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";+import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.service";@NgModule({imports: [@@ -48,6 +49,9 @@ import {BCFNewSplitComponent} from "core-app/modules/ifc_models/bcf/new-split/bcstates: IFC_ROUTES})],+ providers: [+ IFCViewerService+ ],declarations: [// PagesIFCViewerPageComponent,diff --git a/frontend/src/app/modules/time_entries/form/form.component.ts b/frontend/src/app/modules/time_entries/form/form.component.tsindex 65f7d2e50ac..e97416480d5 100644--- a/frontend/src/app/modules/time_entries/form/form.component.ts+++ b/frontend/src/app/modules/time_entries/form/form.component.ts@@ -64,6 +64,7 @@ export class TimeEntryFormComponent implements OnInit, OnDestroy {public signalModifiedEntry($event:{savedResource:HalResource, isInital:boolean}) {this.modifiedEntry.emit($event as {savedResource:TimeEntryResource, isInital:boolean});}+public save() {return this.editForm.save();}diff --git a/modules/bim/spec/features/bcf/create_spec.rb b/modules/bim/spec/features/bcf/create_spec.rbindex 78f783876ea..3492c84ab17 100644--- a/modules/bim/spec/features/bcf/create_spec.rb+++ b/modules/bim/spec/features/bcf/create_spec.rb@@ -3,7 +3,9 @@ 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(:project) do+ FactoryBot.create(:project, types: [type, type_with_cf], work_package_custom_fields: [integer_cf])+ endlet(: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) }@@ -21,6 +23,12 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false douploader: user)endlet(: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)+ endbefore dologin_as(user)@@ -34,6 +42,15 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false docreate_page.expect_current_pathcreate_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!# TODO: adapt notification message@@ -44,34 +61,10 @@ describe 'Create BCF', type: :feature, js: true, with_mail: false dowork_package = WorkPackage.lastindex_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'endendcontext 'without create permission' dolet(: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- #endendenddiff --git a/modules/bim/spec/support/pages/bcf/create_split.rb b/modules/bim/spec/support/pages/bcf/create_split.rbindex 16fc9e70b2d..fad4569316c 100644--- a/modules/bim/spec/support/pages/bcf/create_split.rb+++ b/modules/bim/spec/support/pages/bcf/create_split.rb@@ -61,6 +61,10 @@ module Pages.to have_current_path(path)end+ def container+ find("bcf-new-split")+ end+privatedef default?diff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rbindex f9263a695b0..c6643671678 100644--- a/spec/support/pages/work_packages/abstract_work_package.rb+++ b/spec/support/pages/work_packages/abstract_work_package.rb@@ -269,10 +269,6 @@ module Pagesfind('#types-context-menu .menu-item', text: type.name.upcase, wait: 10).clickend- def select_type(type)- find('.inline-edit--container.type option', text: type.name.upcase).select_option- end-def subject_fieldexpect(page).to have_selector('.inline-edit--container.subject input', wait: 10)find('.inline-edit--container.subject input')