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

[31969] Single BCF view / work packages in BIM (#8074)

Oliver Günther5c3e80141867
diff --git a/app/assets/stylesheets/layout/work_packages/_details_view.sass b/app/assets/stylesheets/layout/work_packages/_details_view.sass
index f3f0fbb165d..2d14158d127 100644
--- a/app/assets/stylesheets/layout/work_packages/_details_view.sass
+++ b/app/assets/stylesheets/layout/work_packages/_details_view.sass
@@ -28,7 +28,7 @@
// Right part of the split view
// Visible only in the details ui-view
-body.router--work-packages-split-view,
+body.router--work-packages-partitioned-split-view,
body.router--work-packages-split-view-new
.work-packages-partitioned-page--content-right
diff --git a/app/assets/stylesheets/layout/work_packages/_mobile.sass b/app/assets/stylesheets/layout/work_packages/_mobile.sass
index 1bafb3e4205..c06908b274c 100644
--- a/app/assets/stylesheets/layout/work_packages/_mobile.sass
+++ b/app/assets/stylesheets/layout/work_packages/_mobile.sass
@@ -136,7 +136,7 @@
.work-packages-full-view--split-container
border-top: none
- .router--work-packages-split-view,
+ .router--work-packages-partitioned-split-view,
.router--work-packages-split-view-new
.work-packages-partitioned-page--content-right
overflow-x: auto
diff --git a/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts b/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
index a4e8b9455ba..5c0171e6d89 100644
--- a/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
+++ b/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
@@ -44,12 +44,35 @@ export class CardClickHandler implements CardEventHandler {
// Locate the card from event
let element = target.closest('wp-single-card');
let wpId = element.data('workPackageId');
- let classIdentifier = element.data('classIdentifier');
if (!wpId) {
return true;
}
+ this.handleWorkPackage(wpId, element, evt);
+
+ return false;
+ }
+
+
+ protected handleWorkPackage(wpId:any, element:JQuery, evt:JQuery.TriggeredEvent) {
+ this.setSelection(wpId, element, evt);
+
+ // open work package on mobile after first click
+ this.openFullViewOnMobile(wpId);
+ }
+
+ protected openFullViewOnMobile(wpId:string) {
+ if (this.deviceService.isMobile) {
+ this.$state.go(
+ 'work-packages.show',
+ {workPackageId: wpId}
+ );
+ }
+ }
+
+ protected setSelection(wpId:string, element:JQuery, evt:JQuery.TriggeredEvent) {
+ let classIdentifier = element.data('classIdentifier');
let index = this.wpCardView.findRenderedCard(classIdentifier);
// Update single selection if no modifier present
@@ -71,15 +94,6 @@ export class CardClickHandler implements CardEventHandler {
// not matter what other card are (de-)selected below.
// Thus save that card for the details view button.
this.wpTableFocus.updateFocus(wpId);
-
- // open work package on mobile after first click
- if (this.deviceService.isMobile) {
- this.$state.go(
- 'work-packages.show',
- {workPackageId: wpId}
- );
- }
-
- return false;
}
+
}
diff --git a/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts b/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
index 08b89cdd65e..f1490da44d6 100644
--- a/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
+++ b/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
@@ -41,11 +41,16 @@ export class CardDblClickHandler implements CardEventHandler {
return true;
}
+ this.handleWorkPackage(wpId);
+
+ return false;
+ }
+
+ protected handleWorkPackage(wpId:string) {
this.$state.go(
'work-packages.show',
{workPackageId: wpId}
);
- return false;
}
}
diff --git a/frontend/src/app/components/wp-card-view/wp-card-view.component.ts b/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
index a78b95400ab..175a600599d 100644
--- a/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
+++ b/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
@@ -4,10 +4,10 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
- EventEmitter,
+ EventEmitter, Inject,
Injector,
Input,
- OnInit,
+ OnInit, Optional,
Output,
ViewChild
} from "@angular/core";
@@ -29,11 +29,18 @@ import {PathHelperService} from "core-app/modules/common/path-helper/path-helper
import {filter, withLatestFrom} from 'rxjs/operators';
import {CausedUpdatesService} from "core-app/modules/boards/board/caused-updates/caused-updates.service";
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
-import {CardViewHandlerRegistry} from "core-components/wp-card-view/event-handler/card-view-handler-registry";
+import {
+ CardEventHandler,
+ CardViewHandlerRegistry
+} from "core-components/wp-card-view/event-handler/card-view-handler-registry";
import {WorkPackageCardViewService} from "core-components/wp-card-view/services/wp-card-view.service";
import {WorkPackageCardDragAndDropService} from "core-components/wp-card-view/services/wp-card-drag-and-drop.service";
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";
import {DeviceService} from "core-app/modules/common/browser/device.service";
+import {
+ WorkPackageViewHandlerClass,
+ WorkPackageViewHandlerToken
+} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
export type CardViewOrientation = 'horizontal'|'vertical';
@@ -143,7 +150,8 @@ export class WorkPackageCardViewComponent implements OnInit, AfterViewInit {
}
// Register event handlers for the cards
- new CardViewHandlerRegistry(this.injector).attachTo(this);
+ let registry = this.injector.get<any>(WorkPackageViewHandlerToken, CardViewHandlerRegistry);
+ new registry(this.injector).attachTo(this);
this.wpTableSelection.registerSelectAllListener(() => { return this.cardView.renderedCards; });
this.wpTableSelection.registerDeselectAllListener();
}
diff --git a/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts b/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
index 30573e1dbb2..854150fa661 100644
--- a/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
+++ b/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
@@ -75,7 +75,7 @@ export class WorkPackageSingleCardComponent implements OnDestroy, OnInit {
let classIdentifier = this.classIdentifier(wp);
this.wpTableSelection.setSelection(wp.id!, this.cardView.findRenderedCard(classIdentifier));
this.$state.go(
- 'work-packages.partitioned.list.details',
+ '.details',
{workPackageId: wp.id!}
);
}
diff --git a/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts b/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts
index 1caeb71aaba..5a9004032de 100644
--- a/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts
+++ b/frontend/src/app/modules/ifc_models/bcf/container/bcf-container.component.ts
@@ -1,4 +1,4 @@
-import {ChangeDetectorRef, Component, Injector, OnDestroy, OnInit} from "@angular/core";
+import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector, OnDestroy, OnInit} from "@angular/core";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {CurrentProjectService} from "core-components/projects/current-project.service";
@@ -10,9 +10,15 @@ import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
import {WorkPackagesListService} from "core-components/wp-list/wp-list.service";
import {UrlParamsHelperService} from "core-components/wp-query/url-params-helper";
import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";
+import {WorkPackageViewHandlerToken} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
+import {BcfCardViewHandlerRegistry} from "core-app/modules/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry";
@Component({
templateUrl: './bcf-container.component.html',
+ providers: [
+ { provide: WorkPackageViewHandlerToken, useValue: BcfCardViewHandlerRegistry }
+ ],
+ changeDetection: ChangeDetectionStrategy.OnPush
})
export class BCFContainerComponent implements OnInit, OnDestroy {
@InjectField() public queryParamListener:QueryParamListenerService;
diff --git a/frontend/src/app/modules/ifc_models/bcf/single-view/bcf-single-view.component.ts b/frontend/src/app/modules/ifc_models/bcf/single-view/bcf-single-view.component.ts
new file mode 100644
index 00000000000..f142880afc7
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/bcf/single-view/bcf-single-view.component.ts
@@ -0,0 +1,56 @@
+// -- 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 {Component, Injector, OnInit} from '@angular/core';
+import {WorkPackageSingleViewBase} from "core-app/modules/work_packages/routing/wp-view-base/work-package-single-view.base";
+import {StateService} from "@uirouter/core";
+
+@Component({
+ selector: 'bcf-single-view',
+ templateUrl: '/app/modules/work_packages/routing/wp-split-view/wp-split-view.html'
+})
+export class BcfSingleViewComponent extends WorkPackageSingleViewBase implements OnInit {
+
+ constructor(public injector:Injector,
+ readonly $state:StateService) {
+ super(injector, $state.params['workPackageId']);
+ }
+
+ ngOnInit():void {
+ this.observeWorkPackage();
+ }
+
+ public close() {
+ this.$state.go('^.^');
+ }
+
+ public switchToFullscreen() {
+ this.$state.go(this.keepTab.currentShowState, this.$state.params);
+ }
+
+}
diff --git a/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts
new file mode 100644
index 00000000000..4c37242cb86
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts
@@ -0,0 +1,19 @@
+import {WorkPackageCardViewComponent} from "core-components/wp-card-view/wp-card-view.component";
+import {
+ CardEventHandler,
+ CardViewHandlerRegistry
+} from "core-components/wp-card-view/event-handler/card-view-handler-registry";
+import {BcfDoubleClickHandler} from "core-app/modules/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler";
+import {BcfClickHandler} from "core-app/modules/ifc_models/ifc-base-view/event-handler/bcf-click-handler";
+
+
+export class BcfCardViewHandlerRegistry extends CardViewHandlerRegistry {
+
+ protected eventHandlers:((c:WorkPackageCardViewComponent) => CardEventHandler)[] = [
+ // Clicking on the card (not within a cell)
+ c => new BcfClickHandler(this.injector, c),
+ // Double clicking on the card
+ c => new BcfDoubleClickHandler(this.injector, c),
+ ];
+}
+
diff --git a/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts
new file mode 100644
index 00000000000..174bf569654
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts
@@ -0,0 +1,12 @@
+import {CardClickHandler} from "core-components/wp-card-view/event-handler/click-handler";
+
+export class BcfClickHandler extends CardClickHandler {
+
+ protected handleWorkPackage(wpId:any, element:JQuery<HTMLElement>, evt:JQuery.TriggeredEvent) {
+ this.setSelection(wpId, element, evt);
+
+ // Open the viewpoint if any
+ // ...
+ }
+
+}
diff --git a/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts
new file mode 100644
index 00000000000..00da0b7d088
--- /dev/null
+++ b/frontend/src/app/modules/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts
@@ -0,0 +1,11 @@
+import {StateService} from "@uirouter/core";
+import {CardDblClickHandler} from "core-components/wp-card-view/event-handler/double-click-handler";
+import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
+
+export class BcfDoubleClickHandler extends CardDblClickHandler {
+ @InjectField() state:StateService;
+
+ protected handleWorkPackage(wpId:string) {
+ this.state.go('.details', { workPackageId: wpId });
+ }
+}
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 4669e6c1114..3eb39241713 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,10 +38,13 @@ import {BimViewToggleButtonComponent} from "core-app/modules/ifc_models/toolbar/
import {BimViewToggleDropdownDirective} from "core-app/modules/ifc_models/toolbar/view-toggle/bim-view-toggle-dropdown.directive";
import {BimManageIfcModelsButtonComponent} from "core-app/modules/ifc_models/toolbar/manage-ifc-models-button/bim-manage-ifc-models-button.component";
import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.service";
+import {BcfSingleViewComponent} from "core-app/modules/ifc_models/bcf/single-view/bcf-single-view.component";
+import {OpenprojectFieldsModule} from "core-app/modules/fields/openproject-fields.module";
@NgModule({
imports: [
OpenprojectCommonModule,
+ OpenprojectFieldsModule,
OpenprojectWorkPackagesModule,
UIRouterModule.forChild({
states: IFC_ROUTES
@@ -63,6 +66,7 @@ import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewe
BimViewToggleButtonComponent,
BimViewToggleDropdownDirective,
+ BcfSingleViewComponent,
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 dad005119fd..49eea309b09 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
@@ -25,75 +25,51 @@
//
// See doc/COPYRIGHT.rdoc for more details.
// ++
-import {Ng2StateDeclaration, UIRouter} from '@uirouter/angular';
+import {Ng2StateDeclaration} 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 {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 {BcfSingleViewComponent} from "core-app/modules/ifc_models/bcf/single-view/bcf-single-view.component";
+import {makeSplitViewRoutes} from "core-app/modules/work_packages/routing/split-view-routes.template";
+
export const IFC_ROUTES:Ng2StateDeclaration[] = [
{
name: 'bim',
parent: 'root',
- url: '/ifc_models?query_props',
+ url: '/bcf?query_props&models',
abstract: true,
component: WorkPackagesBaseComponent,
- redirectTo: 'bim.partitioned.defaults',
+ redirectTo: 'bim.partitioned.split',
params: {
// Use custom encoder/decoder that ensures validity of URL string
- query_props: {type: 'opQueryString', dynamic: true}
+ query_props: {type: 'opQueryString', dynamic: true},
+ models: {type: 'opQueryString', dynamic: true}
}
},
{
name: 'bim.partitioned',
url: '',
- component: IFCViewerPageComponent
+ component: IFCViewerPageComponent,
+ redirectTo: 'bim.partitioned.split',
},
{
name: 'bim.partitioned.list',
url: '/list',
data: {
- viewRoute: 'bim.partitioned.defaults',
- partition: '-right-only'
- },
- reloadOnSearch: false,
- views: {
- 'content-right': { component: BCFContainerComponent }
- }
- },
- {
- name: 'bim.partitioned.defaults',
- url: '/defaults',
- data: {
- viewRoute: 'bim.partitioned.defaults',
- partition: '-split'
- },
- reloadOnSearch: false,
- views: {
- 'content-left': { component: IFCViewerComponent },
- 'content-right': { component: BCFContainerComponent }
- }
- },
- {
- name: 'bim.partitioned.defaults.model',
- url: '/model',
- data: {
- viewRoute: 'bim.partitioned.defaults',
partition: '-left-only'
},
reloadOnSearch: false,
views: {
- // Retarget and by that override the grandparent views
- // https://ui-router.github.io/guide/views#relative-parent-state
- 'content-right@^.^': { component: EmptyComponent }
+ 'content-left': { component: BCFContainerComponent }
}
},
{
- name: 'bim.partitioned.show',
- url: '/{model_id:[0-9]+}',
+ name: 'bim.partitioned.split',
+ url: '/split',
data: {
- viewRoute: 'bim.partitioned.show',
partition: '-split'
},
reloadOnSearch: false,
@@ -103,17 +79,30 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
}
},
{
- name: 'bim.partitioned.show.model',
+ name: 'bim.partitioned.model',
url: '/model',
data: {
- viewRoute: 'bim.partitioned.show',
partition: '-left-only'
},
reloadOnSearch: false,
views: {
// Retarget and by that override the grandparent views
- // https://ui-router.github.io/guide/views#relative-parent-state
- 'content-right@^.^': { component: EmptyComponent }
+ // https://ui-router.github.io/guide/views#relative-parent-state{
+ 'content-right@^': { component: EmptyComponent },
+ 'content-left': { component: IFCViewerComponent }
}
},
+ // BCF single view for list
+ ...makeSplitViewRoutes(
+ 'bim.partitioned.list',
+ undefined,
+ BcfSingleViewComponent
+ ),
+ // BCF single view for split
+ ...makeSplitViewRoutes(
+ 'bim.partitioned.split',
+ undefined,
+ BcfSingleViewComponent
+ )
];
+
diff --git a/frontend/src/app/modules/ifc_models/pages/viewer/bim-view.service.ts b/frontend/src/app/modules/ifc_models/pages/viewer/bim-view.service.ts
index 8dd63da2caa..9205708e6d1 100644
--- a/frontend/src/app/modules/ifc_models/pages/viewer/bim-view.service.ts
+++ b/frontend/src/app/modules/ifc_models/pages/viewer/bim-view.service.ts
@@ -77,7 +77,7 @@ export class BimViewService implements OnDestroy {
}
public currentViewerState():BimViewState {
- if (this.state.current.name === 'bim.partitioned.list') {
+ if (this.state.includes('bim.partitioned.list')) {
return bimListViewIdentifier;
} else if (this.state.includes('bim.**.model')) {
return bimViewerViewIdentifier;
@@ -86,10 +86,6 @@ export class BimViewService implements OnDestroy {
}
}
- public get isSingleModel():boolean {
- return this.state.includes('bim.**.show');
- }
-
private detectView() {
this._state.putValue(this.currentViewerState());
}
diff --git a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-models-data.service.ts b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-models-data.service.ts
index b91c86cc1ba..cf50114fb10 100644
--- a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-models-data.service.ts
+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-models-data.service.ts
@@ -4,13 +4,27 @@ import {PathHelperService} from "core-app/modules/common/path-helper/path-helper
import {GonService} from "core-app/modules/common/gon/gon.service";
import {CurrentProjectService} from "core-components/projects/current-project.service";
+export interface IFCPermissionMap {
+ manage:boolean;
+}
+
+export interface IFCGonDefinition {
+ models:IfcModelDefinition[];
+ shown_models:number[];
+ projects:{ id:string, name:string }[];
+ xkt_attachment_ids:{ [id:number]:number };
+ metadata_attachment_ids:{ [id:number]:number };
+ permissions:IFCPermissionMap;
+}
+
export interface IfcModelDefinition {
name:string;
- id:string;
+ id:number;
+ default:boolean;
saoEnabled:boolean;
}
-@Injectable({ providedIn: OpenprojectIFCModelsModule })
+@Injectable({providedIn: OpenprojectIFCModelsModule})
export class IfcModelsDataService {
constructor(readonly paths:PathHelperService,
@@ -19,7 +33,21 @@ export class IfcModelsDataService {
}
public get models():IfcModelDefinition[] {
- return this.gonIFC['models'];
+ return this.gonIFC.models;
+ }
+
+ public get shownModels():number[] {
+ return this.gonIFC.shown_models;
+ }
+
+ public isSingleModel() {
+ return this.shownModels.length === 1;
+ }
+
+ public isDefaults():boolean {
+ return !this
+ .models
+ .find(item => item.default && this.shownModels.indexOf(item.id) === -1);
}
public get manageIFCPath() {
@@ -30,7 +58,7 @@ export class IfcModelsDataService {
return this.gonIFC.permissions.manage;
}
- private get gonIFC() {
- return (this.gon.get('ifc_models') as any);
+ private get gonIFC():IFCGonDefinition {
+ return (this.gon.get('ifc_models') as IFCGonDefinition);
}
}
\ No newline at end of file
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 c5a3ee73a97..b4c4533df93 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
@@ -93,7 +93,7 @@ export class IFCViewerPageComponent extends PartitionedQuerySpacePageComponent {
updateTitle(query?:QueryResource) {
if (this.bimView.current === bimListViewIdentifier) {
super.updateTitle(query);
- } else if (this.bimView.isSingleModel) {
+ } else if (this.ifcData.isSingleModel()) {
this.selectedTitle = this.ifcData.models[0].name;
} else {
this.selectedTitle = this.I18n.t('js.ifc_models.models.default');
diff --git a/frontend/src/app/modules/ifc_models/toolbar/view-toggle/bim-view-toggle-dropdown.directive.ts b/frontend/src/app/modules/ifc_models/toolbar/view-toggle/bim-view-toggle-dropdown.directive.ts
index 0aeb0942768..239241d8752 100644
--- a/frontend/src/app/modules/ifc_models/toolbar/view-toggle/bim-view-toggle-dropdown.directive.ts
+++ b/frontend/src/app/modules/ifc_models/toolbar/view-toggle/bim-view-toggle-dropdown.directive.ts
@@ -85,10 +85,10 @@ export class BimViewToggleDropdownDirective extends OpContextMenuTrigger {
this.state.go('bim.partitioned.list');
break;
case bimViewerViewIdentifier:
- this.state.go(viewRoute + '.model');
+ this.state.go('bim.partitioned.model');
break;
case bimSplitViewIdentifier:
- this.state.go(viewRoute);
+ this.state.go('bim.partitioned.split');
break;
}
diff --git a/frontend/src/app/modules/ifc_models/xeokit/xeokit-server.js b/frontend/src/app/modules/ifc_models/xeokit/xeokit-server.js
index ba2601d24b5..8bcc63f0127 100644
--- a/frontend/src/app/modules/ifc_models/xeokit/xeokit-server.js
+++ b/frontend/src/app/modules/ifc_models/xeokit/xeokit-server.js
@@ -34,7 +34,7 @@ class XeokitServer {
name: projectData[0].name,
models: window.gon.ifc_models.models,
viewerContent: {
- modelsLoaded: window.gon.ifc_models.default_models
+ modelsLoaded: window.gon.ifc_models.shown_models
},
viewerConfigs: {
saoEnabled: true // Needs to be enabled by default if we want to use it selectively on the available models.
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 57bc883fdb6..2a13a289bf6 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
@@ -487,6 +487,19 @@ import {WorkPackageSettingsButtonComponent} from "core-components/wp-buttons/wp-
WorkPackageIsolatedGraphQuerySpaceDirective,
QueryFiltersComponent,
+ // Needed so that e.g. IFC can access it.
+ WorkPackageCreateButtonComponent,
+ WorkPackageTypeStatusComponent,
+ WorkPackageEditActionsBarComponent,
+ WorkPackageSingleViewComponent,
+ WpResizerDirective,
+ WorkPackageBreadcrumbComponent,
+ WorkPackageBreadcrumbParentComponent,
+ WorkPackageSplitViewToolbarComponent,
+ WorkPackageSubjectComponent,
+ WorkPackageWatchersCountComponent,
+ WorkPackageRelationsCountComponent,
+
// Modals
WpTableConfigurationModalComponent,
WpTableConfigurationFiltersTab,
diff --git a/frontend/src/app/modules/work_packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/modules/work_packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
index aed98fcda43..0b539a61b6e 100644
--- a/frontend/src/app/modules/work_packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
@@ -150,7 +150,7 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp
* @param state The current or entering state
*/
protected setPartition(state:Ng2StateDeclaration) {
- this.currentPartition = state.data.partition || '-split';
+ this.currentPartition = (state.data && state.data.partition) ? state.data.partition : '-split';
}
protected setupInformationLoadedListener() {
diff --git a/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts
new file mode 100644
index 00000000000..d565dd6c2d4
--- /dev/null
+++ b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts
@@ -0,0 +1,122 @@
+// -- 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 {WorkPackageOverviewTabComponent} from 'core-components/wp-single-view-tabs/overview-tab/overview-tab.component';
+import {WorkPackageActivityTabComponent} from 'core-components/wp-single-view-tabs/activity-panel/activity-tab.component';
+import {WorkPackageRelationsTabComponent} from 'core-components/wp-single-view-tabs/relations-tab/relations-tab.component';
+import {WorkPackageWatchersTabComponent} from 'core-components/wp-single-view-tabs/watchers-tab/watchers-tab.component';
+import {WorkPackageNewFullViewComponent} from 'core-components/wp-new/wp-new-full-view.component';
+import {WorkPackageCopyFullViewComponent} from 'core-components/wp-copy/wp-copy-full-view.component';
+import {WorkPackageNewSplitViewComponent} from 'core-components/wp-new/wp-new-split-view.component';
+import {WorkPackageCopySplitViewComponent} from 'core-components/wp-copy/wp-copy-split-view.component';
+import {WorkPackagesFullViewComponent} from "core-app/modules/work_packages/routing/wp-full-view/wp-full-view.component";
+import {WorkPackageSplitViewComponent} from "core-app/modules/work_packages/routing/wp-split-view/wp-split-view.component";
+import {Ng2StateDeclaration} from "@uirouter/angular";
+import {WorkPackagesBaseComponent} from "core-app/modules/work_packages/routing/wp-base/wp--base.component";
+import {WorkPackageListViewComponent} from "core-app/modules/work_packages/routing/wp-list-view/wp-list-view.component";
+import {WorkPackageViewPageComponent} from "core-app/modules/work_packages/routing/wp-view-page/wp-view-page.component";
+import {WorkPackageSingleViewComponent} from "core-components/work-packages/wp-single-view/wp-single-view.component";
+import {ComponentType} from "@angular/cdk/overlay";
+
+/**
+ * Return a set of routes for a split view mounted under the given base route,
+ * which must be a grandchild of a PartitionedQuerySpacePageComponent.
+ *
+ * Example: base route = foo.bar
+ *
+ * Split view will be created at
+ *
+ * foo.bar.details
+ * foo.bar.details.activity
+ * foo.bar.details.relations
+ * foo.bar.details.watchers
+ *
+ * NOTE: All parameters here must either be `export const` or literal strings,
+ * otherwise AOT will not be able to look them up. This might result in missing routes.
+ *
+ * @param baseRoute The base route to mount under
+ * @param component The split view component to mount
+ */
+export function makeSplitViewRoutes(baseRoute:string,
+ menuItemClass:string|undefined,
+ component:ComponentType<any>):Ng2StateDeclaration[] {
+ return [
+ {
+ name: baseRoute + '.details',
+ url: '/details/{workPackageId:[0-9]+}',
+ redirectTo: baseRoute + '.details.overview',
+ reloadOnSearch: false,
+ data: {
+ bodyClasses: 'router--work-packages-partitioned-split-view',
+ menuItem: menuItemClass,
+ partition: '-split'
+ },
+ views: {
+ // Retarget and by that override the grandparent views
+ // https://ui-router.github.io/guide/views#relative-parent-state
+ 'content-right@^.^': {component: component}
+ }
+ },
+ {
+ name: baseRoute + '.details.overview',
+ url: '/overview',
+ component: WorkPackageOverviewTabComponent,
+ data: {
+ menuItem: menuItemClass,
+ parent: baseRoute + '.details'
+ }
+ },
+ {
+ name: baseRoute + '.details.activity',
+ url: '/activity',
+ component: WorkPackageActivityTabComponent,
+ data: {
+ menuItem: menuItemClass,
+ parent: baseRoute + '.details'
+ }
+ },
+ {
+ name: baseRoute + '.details.relations',
+ url: '/relations',
+ component: WorkPackageRelationsTabComponent,
+ data: {
+ menuItem: menuItemClass,
+ parent: baseRoute + '.details'
+ }
+ },
+ {
+ name: baseRoute + '.details.watchers',
+ url: '/watchers',
+ component: WorkPackageWatchersTabComponent,
+ data: {
+ menuItem: menuItemClass,
+ parent: baseRoute + '.details'
+ }
+ },
+ ];
+}
diff --git a/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts b/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
index 5e39ae5796c..94cd800c60e 100644
--- a/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
+++ b/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
@@ -26,7 +26,6 @@
// See docs/COPYRIGHT.rdoc for more details.
// ++
-import {WorkPackageOverviewTabComponent} from 'core-components/wp-single-view-tabs/overview-tab/overview-tab.component';
import {WorkPackageActivityTabComponent} from 'core-components/wp-single-view-tabs/activity-panel/activity-tab.component';
import {WorkPackageRelationsTabComponent} from 'core-components/wp-single-view-tabs/relations-tab/relations-tab.component';
import {WorkPackageWatchersTabComponent} from 'core-components/wp-single-view-tabs/watchers-tab/watchers-tab.component';
@@ -40,8 +39,9 @@ import {Ng2StateDeclaration} from "@uirouter/angular";
import {WorkPackagesBaseComponent} from "core-app/modules/work_packages/routing/wp-base/wp--base.component";
import {WorkPackageListViewComponent} from "core-app/modules/work_packages/routing/wp-list-view/wp-list-view.component";
import {WorkPackageViewPageComponent} from "core-app/modules/work_packages/routing/wp-view-page/wp-view-page.component";
+import {makeSplitViewRoutes} from "core-app/modules/work_packages/routing/split-view-routes.template";
-const menuItemClass = 'work-packages-menu-item';
+export const menuItemClass = 'work-packages-menu-item';
export const WORK_PACKAGES_ROUTES:Ng2StateDeclaration[] = [
{
@@ -175,75 +175,16 @@ export const WORK_PACKAGES_ROUTES:Ng2StateDeclaration[] = [
reloadOnSearch: false,
data: {
allowMovingInEditMode: true,
- bodyClasses: 'router--work-packages-split-view',
+ bodyClasses: 'router--work-packages-partitioned-split-view',
menuItem: menuItemClass,
parent: 'work-packages.partitioned.list'
},
},
- {
- name: 'work-packages.partitioned.list.details',
- redirectTo: 'work-packages.partitioned.list.details.overview',
- url: '/details/{workPackageId:[0-9]+}',
- views: {
- 'content-right@^.^': { component: WorkPackageSplitViewComponent }
- },
- reloadOnSearch: false,
- params: {
- focus: {
- dynamic: true,
- value: true
- }
- },
- data: {
- bodyClasses: 'router--work-packages-split-view',
- menuItem: menuItemClass
- },
- },
- {
- name: 'work-packages.partitioned.list.details.overview',
- url: '/overview',
- component: WorkPackageOverviewTabComponent,
- data: {
- parent: 'work-packages.partitioned.list.details',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.partitioned.list.details.activity',
- url: '/activity',
- component: WorkPackageActivityTabComponent,
- data: {
- parent: 'work-packages.partitioned.list.details',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.partitioned.list.details.activity.details',
- url: '/activity/details/#{activity_no:\d+}',
- component: WorkPackageActivityTabComponent,
- data: {
- parent: 'work-packages.partitioned.list.details',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.partitioned.list.details.relations',
- url: '/relations',
- component: WorkPackageRelationsTabComponent,
- data: {
- parent: 'work-packages.partitioned.list.details',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.partitioned.list.details.watchers',
- url: '/watchers',
- component: WorkPackageWatchersTabComponent,
- data: {
- parent: 'work-packages.partitioned.list.details',
- menuItem: menuItemClass
- }
- },
+ ...makeSplitViewRoutes(
+ 'work-packages.partitioned.list',
+ menuItemClass,
+ WorkPackageSplitViewComponent
+ )
// Avoid lazy-loading the routes for now
// {
// name: 'work-packages.calendar.**',
diff --git a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
index f696f77e74f..8957ed7a3c5 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
@@ -5,21 +5,21 @@
<ul class="tabrow">
<!-- The hrefs with empty URLs are necessary for IE10 to focus these links
properly. Thus, don't remove the hrefs or the empty URLs! -->
- <li uiSref="work-packages.partitioned.list.details.overview"
+ <li uiSref=".overview"
uiSrefActive="selected">
<a href="" [textContent]="text.tabs.overview"></a>
</li>
- <li uiSref="work-packages.partitioned.list.details.activity"
+ <li uiSref=".activity"
uiSrefActive="selected">
<a href="" [textContent]="text.tabs.activity"></a>
</li>
- <li uiSref="work-packages.partitioned.list.details.relations"
+ <li uiSref=".relations"
uiSrefActive="selected">
<a href="" [textContent]="text.tabs.relations"></a>
<wp-relations-count [wpId]="workPackage.id"></wp-relations-count>
</li>
<li *ngIf="canViewWorkPackageWatchers()"
- uiSref="work-packages.partitioned.list.details.watchers"
+ uiSref=".watchers"
uiSrefActive="selected">
<a href="" [textContent]="text.tabs.watchers"></a>
<wp-watchers-count [wpId]="workPackage.id"></wp-watchers-count>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
index e4b919f82c9..da080c7ca99 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
@@ -1,4 +1,4 @@
-import {Injector} from '@angular/core';
+import {InjectionToken, Injector} from '@angular/core';
export interface WorkPackageViewEventHandler<T> {
/** Event name to register **/
@@ -14,6 +14,12 @@ export interface WorkPackageViewEventHandler<T> {
eventScope(view:T):JQuery;
}
+export interface WorkPackageViewHandlerClass<T> {
+ new(injector:Injector):WorkPackageViewEventHandler<any>;
+}
+
+export const WorkPackageViewHandlerToken = new InjectionToken<WorkPackageViewEventHandler<any>>('CardEventHandler');
+
/**
* Abstract view handler registry for globally handling arbitrary event on the
* view container. Used e.g., for table to register single event callbacks for the entirety
diff --git a/modules/bim/app/assets/stylesheets/bim/ifc_viewer/generic.sass b/modules/bim/app/assets/stylesheets/bim/ifc_viewer/generic.sass
index 897a3a246a1..267e45dc184 100644
--- a/modules/bim/app/assets/stylesheets/bim/ifc_viewer/generic.sass
+++ b/modules/bim/app/assets/stylesheets/bim/ifc_viewer/generic.sass
@@ -12,11 +12,10 @@
// The IFC viewer shall fill the viewport to the bottom.
// This is different to how we style #content else where.
-.controller-bim\/ifc_models\/ifc_models
+.controller-bim\/ifc_models\/ifc_viewer
overflow: hidden
- &.action-show,
- &.action-defaults
+ &.action-show
#content
height: 100%
diff --git a/modules/bim/app/cells/bim/ifc_models/row_cell.rb b/modules/bim/app/cells/bim/ifc_models/row_cell.rb
index 1744777d14b..7b3a304f04b 100644
--- a/modules/bim/app/cells/bim/ifc_models/row_cell.rb
+++ b/modules/bim/app/cells/bim/ifc_models/row_cell.rb
@@ -10,7 +10,7 @@ module Bim
model.title
else
link_to model.title,
- ifc_models_project_ifc_model_path(model.project, model)
+ bcf_project_ifc_model_path(model.project, model)
end
end
@@ -53,7 +53,7 @@ module Bim
def delete_link
link_to '',
- ifc_models_project_ifc_model_path(model.project, model),
+ bcf_project_ifc_model_path(model.project, model),
class: 'icon icon-delete',
data: { confirm: I18n.t(:text_are_you_sure) },
method: :delete
@@ -61,7 +61,7 @@ module Bim
def edit_link
link_to '',
- edit_ifc_models_project_ifc_model_path(model.project, model),
+ edit_bcf_project_ifc_model_path(model.project, model),
class: 'icon icon-edit',
accesskey: accesskey(:edit)
end
diff --git a/modules/bim/app/cells/bim/ifc_models/table_cell.rb b/modules/bim/app/cells/bim/ifc_models/table_cell.rb
index 4d52216380c..35c4f7fc6f7 100644
--- a/modules/bim/app/cells/bim/ifc_models/table_cell.rb
+++ b/modules/bim/app/cells/bim/ifc_models/table_cell.rb
@@ -13,7 +13,7 @@ module Bim
end
def inline_create_link
- link_to(new_ifc_models_project_ifc_model_path,
+ link_to(new_bcf_project_ifc_model_path,
class: 'wp-inline-create--add-link',
title: I18n.t('ifc_models.label_new_ifc_model')) do
op_icon('icon icon-add')
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
index d31a8b75e2e..8bdfb37cb3d 100644
--- a/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_models_controller.rb
@@ -34,7 +34,7 @@ module Bim
helper_method :gon
before_action :find_project_by_project_id, only: %i[index new create show defaults edit update destroy]
- before_action :find_ifc_model_object, except: %i[index new create]
+ before_action :find_ifc_model_object, only: %i[edit update destroy]
before_action :find_all_ifc_models, only: %i[show defaults index]
before_action :authorize
@@ -53,13 +53,16 @@ module Bim
def edit;
end
- def show;
+ def show
+ frontend_redirect params[:id].to_i
end
def defaults
@default_ifc_models = @ifc_models.defaults
- if @default_ifc_models.empty?
+ if @default_ifc_models.exists?
+ frontend_redirect @default_ifc_models.pluck(:id).uniq
+ else
redirect_to action: :index
end
end
@@ -111,11 +114,15 @@ module Bim
private
+ def frontend_redirect(model_ids)
+ redirect_to bcf_project_frontend_path(models: JSON.dump(Array(model_ids)))
+ end
+
def find_all_ifc_models
@ifc_models = @project
.ifc_models
.includes(:attachments)
- .order('created_at ASC')
+ .order("#{IfcModels::IfcModel.table_name}.created_at ASC")
end
def permitted_model_params
diff --git a/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb b/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb
new file mode 100644
index 00000000000..090c0ed5e14
--- /dev/null
+++ b/modules/bim/app/controllers/bim/ifc_models/ifc_viewer_controller.rb
@@ -0,0 +1,72 @@
+#-- encoding: UTF-8
+
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# 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 Bim
+ module IfcModels
+ class IfcViewerController < BaseController
+ helper_method :gon
+
+ before_action :find_project_by_project_id
+ before_action :authorize
+ before_action :find_all_ifc_models
+ before_action :set_default_models
+ before_action :parse_showing_models
+
+ menu_item :ifc_models
+
+
+ def show; end
+
+ private
+
+ def parse_showing_models
+ @shown_model_ids =
+ if params[:models]
+ JSON.parse(params[:models])
+ else
+ []
+ end
+
+ @shown_ifc_models = @ifc_models.select { |model| @shown_model_ids.include?(model.id) }
+ end
+
+ def find_all_ifc_models
+ @ifc_models = @project
+ .ifc_models
+ .includes(:attachments)
+ .order('created_at ASC')
+ end
+
+ def set_default_models
+ @default_ifc_models = @ifc_models.where(is_default: true)
+ end
+ end
+ end
+end
diff --git a/modules/bim/app/helpers/ifc_models_helper.rb b/modules/bim/app/helpers/ifc_models_helper.rb
index fba541aa6d3..0c4fac53114 100644
--- a/modules/bim/app/helpers/ifc_models_helper.rb
+++ b/modules/bim/app/helpers/ifc_models_helper.rb
@@ -1,10 +1,10 @@
module IfcModelsHelper
- def provision_gon_for_ifc_model(all_models, models_to_load = [])
+ def provision_gon_for_ifc_model(all_models, shown_models)
all_converted_models = converted_ifc_models(all_models)
gon.ifc_models = {
- models: gon_ifc_model_models(all_converted_models, models_to_load),
- default_models: gon_ifc_default_models(all_converted_models, models_to_load),
+ models: gon_ifc_model_models(all_converted_models),
+ shown_models: gon_ifc_shown_models(all_converted_models, shown_models),
projects: [{id: @project.identifier, name: @project.name}],
xkt_attachment_ids: gon_ifc_model_xkt_attachment_ids(all_converted_models),
metadata_attachment_ids: gon_ifc_model_metadata_attachment_ids(all_converted_models),
@@ -18,26 +18,23 @@ module IfcModelsHelper
ifc_models.select(&:converted?)
end
- def gon_ifc_model_models(all_models, models_to_load)
+ def gon_ifc_model_models(all_models)
all_converted_models = converted_ifc_models(all_models)
all_converted_models.map do |ifc_model|
{
id: ifc_model.id,
name: ifc_model.title,
- saoEnabled: models_to_load.include?(ifc_model)
+ default: ifc_model.is_default,
+ saoEnabled: ifc_model.is_default
}
end
end
- def gon_ifc_default_models(all_models, models_to_load)
- all_converted_models = converted_ifc_models(all_models)
- default_models = []
-
- all_converted_models.map do |ifc_model|
- default_models << ifc_model.id.to_s if models_to_load.include?(ifc_model)
- end
- default_models
+ def gon_ifc_shown_models(all_models, shown_models)
+ converted_ifc_models(all_models)
+ .select { |model| shown_models.include?(model.id) }
+ .map(&:id)
end
def gon_ifc_model_xkt_attachment_ids(models)
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/_no_default_notice.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/_no_default_notice.html.erb
index fd2060193f6..9366b01e4ed 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/_no_default_notice.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_models/_no_default_notice.html.erb
@@ -5,8 +5,8 @@
<li><%= t('ifc_models.no_defaults_warning.check_1') %></li>
<li><%= t('ifc_models.no_defaults_warning.check_2') %></li>
</ul>
- <% unless current_page?(ifc_models_project_ifc_models_path(project)) %>
- <%= link_to(ifc_models_project_ifc_models_path(project), class: 'button', accesskey: accesskey(:edit)) do %>
+ <% unless current_page?(bcf_project_ifc_models_path(project)) %>
+ <%= link_to(bcf_project_ifc_models_path(project), class: 'button', accesskey: accesskey(:edit)) do %>
<%= op_icon('button--icon icon-edit') %> <%= t('ifc_models.label_edit_defaults') %>
<% end %>
<% end %>
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/_show_headers.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/_show_headers.html.erb
deleted file mode 100644
index d0d864696dc..00000000000
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/_show_headers.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<% content_for :header_tags do %>
- <%= stylesheet_link_tag "bim/ifc_viewer/generic", media: 'all' %>
- <% provision_gon_for_ifc_model(all_models, selected_models) %>
- <%= include_gon(nonce: content_security_policy_script_nonce) %>
-<% end %>
-
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/defaults.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/defaults.html.erb
deleted file mode 100644
index db01c061e67..00000000000
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/defaults.html.erb
+++ /dev/null
@@ -1,48 +0,0 @@
-<%#-- copyright
-OpenProject Documents Plugin
-
-Former OpenProject Core functionality extracted into a plugin.
-
-Copyright (C) 2009-2014 the OpenProject Foundation (OPF)
-
-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 doc/COPYRIGHT.rdoc for more details.
-
-++#%>
-
-<% html_title t('ifc_models.label_default_ifc_models') -%>
-
-<%= render partial: 'show_headers', locals: { all_models: @ifc_models, selected_models: @default_ifc_models } %>
-
-<% if @default_ifc_models.empty? %>
- <%= render partial: 'no_default_notice', locals: { project: @project } %>
-<% else %>
- <% unconverted = @default_ifc_models.reject(&:converted?) %>
-
- <% if unconverted.any? %>
- <%= render partial: 'unconverted_notice', locals: { unconverted: unconverted } %>
- <% end %>
-
- <openproject-base></openproject-base>
-<% end %>
-
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/edit.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/edit.html.erb
index 5dee3019518..61439c67119 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/edit.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_models/edit.html.erb
@@ -32,7 +32,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= toolbar title: Bim::IfcModels::IfcModel.model_name.human %>
-<%= labelled_tabular_form_for @ifc_model, url: ifc_models_project_ifc_model_path(@project, @ifc_model), method: 'PATCH' do |f| -%>
+<%= labelled_tabular_form_for @ifc_model, url: bcf_project_ifc_model_path(@project, @ifc_model), method: 'PATCH' do |f| -%>
<%= error_messages_for_contract @ifc_model, @errors %>
<%= render partial: 'form', locals: { f: f } %>
<%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %>
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/index.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/index.html.erb
index eafa0da2cc6..1263ed73d46 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/index.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_models/index.html.erb
@@ -31,7 +31,7 @@ See docs/COPYRIGHT.rdoc for more details.
<%= toolbar title: t('ifc_models.label_ifc_models') do %>
<% if User.current.allowed_to?(:manage_ifc_models, @project) %>
<li class="toolbar-item">
- <%= link_to new_ifc_models_project_ifc_model_path,
+ <%= link_to new_bcf_project_ifc_model_path,
{ class: 'button -alt-highlight',
aria: { label: t(:'ifc_models.label_new_ifc_model') },
title: t(:'ifc_models.label_new_ifc_model') } do %>
@@ -42,7 +42,7 @@ See docs/COPYRIGHT.rdoc for more details.
<% end %>
<% if @ifc_models.defaults.any? %>
<li class="toolbar-item">
- <%= link_to defaults_ifc_models_project_ifc_models_path,
+ <%= link_to defaults_bcf_project_ifc_models_path,
{ class: 'button',
aria: { label: t('ifc_models.label_show_defaults') },
title: t('ifc_models.label_show_defaults') } do %>
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/new.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/new.html.erb
index 0d1fd61bd75..e8851460e2a 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/new.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_models/new.html.erb
@@ -31,7 +31,7 @@ See doc/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t('ifc_models.label_new_ifc_model') %>
-<%= labelled_tabular_form_for @ifc_model, url: ifc_models_project_ifc_models_path(@project), html: { multipart: true } do |f| -%>
+<%= labelled_tabular_form_for @ifc_model, url: bcf_project_ifc_models_path(@project), html: { multipart: true } do |f| -%>
<%= error_messages_for_contract @ifc_model, @errors %>
<%= render :partial => 'form', locals: { f: f } %>
<%= styled_button_tag l(:button_create), class: "-highlight -with-icon icon-checkmark" %>
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/_unconverted_notice.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_viewer/_unconverted_notice.html.erb
similarity index 100%
rename from modules/bim/app/views/bim/ifc_models/ifc_models/_unconverted_notice.html.erb
rename to modules/bim/app/views/bim/ifc_models/ifc_viewer/_unconverted_notice.html.erb
diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/show.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
similarity index 72%
rename from modules/bim/app/views/bim/ifc_models/ifc_models/show.html.erb
rename to modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
index 9f44e727056..62f033d71c7 100644
--- a/modules/bim/app/views/bim/ifc_models/ifc_models/show.html.erb
+++ b/modules/bim/app/views/bim/ifc_models/ifc_viewer/show.html.erb
@@ -30,10 +30,17 @@ See doc/COPYRIGHT.rdoc for more details.
++#%>
-<% html_title h(@ifc_model.title) -%>
+<% content_for :header_tags do %>
+ <%= stylesheet_link_tag "bim/ifc_viewer/generic", media: 'all' %>
+ <% provision_gon_for_ifc_model(@ifc_models, @shown_model_ids) %>
+ <%= include_gon(nonce: content_security_policy_script_nonce) %>
+<% end %>
-<%= render partial: 'show_headers', locals: { all_models: @ifc_models, selected_models: [@ifc_model] } %>
+<% unconverted = @shown_ifc_models.reject(&:converted?) %>
-<% if @ifc_model.converted? %>
- <openproject-base></openproject-base>
+<% if unconverted.any? %>
+ <%= render partial: 'unconverted_notice', locals: { unconverted: unconverted } %>
<% end %>
+
+
+<openproject-base></openproject-base>
diff --git a/modules/bim/config/routes.rb b/modules/bim/config/routes.rb
index 06a8c6da2b9..edfeb499781 100644
--- a/modules/bim/config/routes.rb
+++ b/modules/bim/config/routes.rb
@@ -38,20 +38,14 @@ OpenProject::Application.routes.draw do
post :import, action: :perform_import, on: :collection
end
- get 'bcf_issues', to: 'bim/bcf/issues#redirect_to_bcf_issues_list', as: :work_packages
- end
- end
- scope '', as: 'ifc_models' do
- scope 'projects/:project_id', as: 'project' do
+ # IFC viewer frontend
+ get 'bcf(/*state)', to: 'bim/ifc_models/ifc_viewer#show', as: :frontend
+
+ # IFC model management
resources :ifc_models, controller: 'bim/ifc_models/ifc_models' do
collection do
- get 'defaults(/*state)', action: :defaults, as: :defaults
- get 'list(/*state)', action: :defaults, as: :list
- end
-
- member do
- get '/*(?!edit)', action: :show
+ get :defaults
end
end
end
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index edd4b0b530b..4d16fa59c41 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -45,7 +45,10 @@ module OpenProject::Bim
project_module(:bim,
if: ->(*) { OpenProject::Configuration.bim? }) do
permission :view_ifc_models,
- {'bim/ifc_models/ifc_models': %i[index show defaults]}
+ {
+ 'bim/ifc_models/ifc_models': %i[index show defaults],
+ 'bim/ifc_models/ifc_viewer': %i[show]
+ }
permission :manage_ifc_models,
{'bim/ifc_models/ifc_models': %i[index show destroy edit update create new]},
dependencies: %i[view_ifc_models]
diff --git a/modules/bim/spec/factories/ifc_model_factory.rb b/modules/bim/spec/factories/ifc_model_factory.rb
index 5a8b151c98a..9bb5f2efc21 100644
--- a/modules/bim/spec/factories/ifc_model_factory.rb
+++ b/modules/bim/spec/factories/ifc_model_factory.rb
@@ -28,7 +28,7 @@
FactoryBot.define do
factory :ifc_model, class: ::Bim::IfcModels::IfcModel do
- title { 'My IFC model' }
+ sequence(:title) { |n| "Unconverted IFC model #{n}" }
project factory: :project
uploader factory: :user
is_default { true }
@@ -40,7 +40,7 @@ FactoryBot.define do
end
factory :ifc_model_converted do
- title { 'My IFC model' }
+ sequence(:title) { |n| "Converted IFC model #{n}" }
project factory: :project
uploader factory: :user
is_default { true }
diff --git a/modules/bim/spec/features/bim_navigation_spec.rb b/modules/bim/spec/features/bim_navigation_spec.rb
index ca07a159bd1..84edf56e6e9 100644
--- a/modules/bim/spec/features/bim_navigation_spec.rb
+++ b/modules/bim/spec/features/bim_navigation_spec.rb
@@ -30,6 +30,7 @@ require 'spec_helper'
require_relative '../support/pages/ifc_models/show'
require_relative '../support/pages/ifc_models/show_default'
+require_relative '../support/pages/ifc_models/bcf_details_page'
describe 'BIM navigation spec', type: :feature, js: true do
let(:project) { FactoryBot.create :project, enabled_module_names: [:bim, :work_package_tracking] }
@@ -49,6 +50,7 @@ describe 'BIM navigation spec', type: :feature, js: true do
end
let(:card_view) { ::Pages::WorkPackageCards.new(project) }
+ let(:details_view) { ::Pages::BcfDetailsPage.new(work_package, project) }
shared_examples 'can switch from split to viewer to list-only' do
@@ -65,7 +67,7 @@ describe 'BIM navigation spec', type: :feature, js: true do
model_page.finished_loading
end
- it 'can switch from split to viewer only to list' do
+ it 'can switch between the different view modes' do
# Should be at split view
model_page.model_viewer_visible true
model_page.model_viewer_shows_a_toolbar true
@@ -74,6 +76,17 @@ describe 'BIM navigation spec', type: :feature, js: true do
expect(page).to have_selector('.wp-cards-container')
card_view.expect_work_package_listed work_package
+ # Go to single view
+ wp_card = card_view.card(work_package)
+ page.driver.browser.action.double_click(wp_card.native).perform
+
+ details_view.ensure_page_loaded
+ details_view.expect_subject
+ details_view.switch_to_tab tab: 'Activity'
+ details_view.expect_tab 'Activity'
+ details_view.close
+ details_view.expect_closed
+
# Go to viewer only
model_page.switch_view 'Viewer only'
@@ -86,6 +99,17 @@ describe 'BIM navigation spec', type: :feature, js: true do
model_page.model_viewer_visible false
expect(page).to have_selector('.wp-cards-container')
card_view.expect_work_package_listed work_package
+
+ # Go to single view
+ wp_card = card_view.card(work_package)
+ page.driver.browser.action.double_click(wp_card.native).perform
+
+ details_view.ensure_page_loaded
+ details_view.expect_subject
+ details_view.switch_to_tab tab: 'Activity'
+ details_view.expect_tab 'Activity'
+ details_view.close
+ details_view.expect_closed
end
end
end
diff --git a/modules/bim/spec/features/model_management_spec.rb b/modules/bim/spec/features/model_management_spec.rb
index 22f37083fe1..6ac28cc0e79 100644
--- a/modules/bim/spec/features/model_management_spec.rb
+++ b/modules/bim/spec/features/model_management_spec.rb
@@ -31,9 +31,9 @@ require 'spec_helper'
require_relative '../support/pages/ifc_models/index'
describe 'model management', type: :feature, js: true do
- let(:project) { FactoryBot.create :project, enabled_module_names: [:bim] }
+ let(:project) { FactoryBot.create :project, enabled_module_names: %i[bim work_package_tracking] }
let(:index_page) { Pages::IfcModels::Index.new(project) }
- let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models]) }
+ let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models view_work_packages]) }
let(:user) do
FactoryBot.create :user,
@@ -47,10 +47,18 @@ describe 'model management', type: :feature, js: true do
uploader: user)
end
+ let(:model2) do
+ FactoryBot.create(:ifc_model_converted,
+ project: project,
+ uploader: user)
+ end
+
+
context 'with all permissions' do
before do
login_as(user)
model
+ model2
index_page.visit!
end
@@ -74,7 +82,7 @@ describe 'model management', type: :feature, js: true do
end
context 'with only viewing permissions' do
- let(:view_role) { FactoryBot.create(:role, permissions: %i[view_ifc_models]) }
+ let(:view_role) { FactoryBot.create(:role, permissions: %i[view_ifc_models view_work_packages]) }
let(:view_user) do
FactoryBot.create :user,
member_in_project: project,
@@ -84,6 +92,7 @@ describe 'model management', type: :feature, js: true do
before do
login_as(view_user)
model
+ model2
index_page.visit!
end
diff --git a/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb b/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb
new file mode 100644
index 00000000000..432740e3412
--- /dev/null
+++ b/modules/bim/spec/support/pages/ifc_models/bcf_details_page.rb
@@ -0,0 +1,39 @@
+#-- 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/work_packages/split_work_package'
+
+module Pages
+ class BcfDetailsPage < Pages::SplitWorkPackage
+ protected
+
+ def path(tab = 'overview')
+ bcf_project_frontend_path project, "split/details/#{work_package.id}/#{tab}"
+ 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..8dfe54cbc55 100644
--- a/modules/bim/spec/support/pages/ifc_models/index.rb
+++ b/modules/bim/spec/support/pages/ifc_models/index.rb
@@ -38,7 +38,7 @@ module Pages
end
def path
- ifc_models_project_ifc_models_path(project)
+ bcf_project_ifc_models_path(project)
end
def model_listed(listed, model_name)
@@ -51,8 +51,8 @@ module Pages
if allowed
click_toolbar_button 'IFC model'
- expect_correct_page_loaded '.button[type="submit"]',
- new_ifc_models_project_ifc_model_path(project)
+ expect_correct_page_loaded '.button[type="submit"]'
+ expect(page).to have_current_path new_bcf_project_ifc_model_path(project)
visit!
else
@@ -81,7 +81,7 @@ module Pages
click_on 'Save'
model_listed true, new_name
- expect(current_path).to eq ifc_models_project_ifc_models_path(project)
+ expect(current_path).to eq bcf_project_ifc_models_path(project)
end
def delete_model(model_name)
@@ -90,14 +90,15 @@ module Pages
page.driver.browser.switch_to.alert.accept
model_listed false, model_name
- expect(current_path).to eq ifc_models_project_ifc_models_path(project)
+ expect(current_path).to eq bcf_project_ifc_models_path(project)
end
def show_model(model)
click_model_link model.title
- expect_correct_page_loaded '.ifc-model-viewer--container',
- ifc_models_project_ifc_model_path(project, model)
+ expect_correct_page_loaded '.ifc-model-viewer--container'
+
+ expect(page).to have_selector('.editable-toolbar-title--fixed', text: model.title)
visit!
end
@@ -105,8 +106,9 @@ module Pages
def show_defaults
click_toolbar_button 'Show defaults'
- expect_correct_page_loaded '.ifc-model-viewer--container',
- defaults_ifc_models_project_ifc_models_path(project)
+ expect_correct_page_loaded '.ifc-model-viewer--container'
+
+ expect(page).to have_selector('.editable-toolbar-title--fixed', text: 'Default IFC models')
visit!
end
@@ -138,9 +140,8 @@ module Pages
end
end
- def expect_correct_page_loaded(checked_selector, path)
+ def expect_correct_page_loaded(checked_selector)
expect(page).to have_selector(checked_selector)
- expect(current_path).to eql path
end
def change_model_name(model_name, new_name)
diff --git a/modules/bim/spec/support/pages/ifc_models/show.rb b/modules/bim/spec/support/pages/ifc_models/show.rb
index 889c9fb2282..5b1eb9db7f9 100644
--- a/modules/bim/spec/support/pages/ifc_models/show.rb
+++ b/modules/bim/spec/support/pages/ifc_models/show.rb
@@ -41,7 +41,7 @@ module Pages
private
def path
- ifc_models_project_ifc_model_path(project, id)
+ bcf_project_ifc_model_path(project, id)
end
end
end
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 b7e3911e626..7b712d340d5 100644
--- a/modules/bim/spec/support/pages/ifc_models/show_default.rb
+++ b/modules/bim/spec/support/pages/ifc_models/show_default.rb
@@ -38,7 +38,7 @@ module Pages
end
def path
- defaults_ifc_models_project_ifc_models_path(project)
+ defaults_bcf_project_ifc_models_path(project)
end
def finished_loading
diff --git a/spec/features/work_packages/table/delete_work_packages_spec.rb b/spec/features/work_packages/table/delete_work_packages_spec.rb
index 2283d1f4d77..1df250379fe 100644
--- a/spec/features/work_packages/table/delete_work_packages_spec.rb
+++ b/spec/features/work_packages/table/delete_work_packages_spec.rb
@@ -55,7 +55,7 @@ describe 'Delete work package', js: true do
end
it 'should close the split view' do
- split_view.closed?
+ split_view.expect_closed
wp_table.expect_current_path
end
end
diff --git a/spec/support/pages/work_packages/split_work_package.rb b/spec/support/pages/work_packages/split_work_package.rb
index 61faf425722..af68906a21c 100644
--- a/spec/support/pages/work_packages/split_work_package.rb
+++ b/spec/support/pages/work_packages/split_work_package.rb
@@ -43,15 +43,19 @@ module Pages
FullWorkPackage.new(work_package, project)
end
- def closed?
+ def expect_closed
expect(page).to have_no_selector(@selector)
end
+ def close
+ find('.work-packages--details-close-icon').click
+ end
+
def container
find(@selector)
end
- private
+ protected
def path(tab = 'overview')
state = "#{work_package.id}/#{tab}"