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
Add routes for split and viewer
Oliver Günthereea1f28e8d55
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.tsindex c62f1bbcf71..c30ae96ed41 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@@ -27,40 +27,14 @@// ++import {NgModule} from "@angular/core";import {OpenprojectWorkPackagesModule} from "core-app/modules/work_packages/openproject-work-packages.module";-import { Ng2StateDeclaration, UIRouterModule, UIRouter } from '@uirouter/angular';-import {IFCIndexPageComponent} from "core-app/modules/ifc_models/pages/index/ifc-index-page.component";+import {UIRouterModule} from '@uirouter/angular';import {OpenprojectCommonModule} from "core-app/modules/common/openproject-common.module";-import { IFCViewerComponent } from './ifc-viewer/ifc-viewer.component';--export const IFC_ROUTES:Ng2StateDeclaration[] = [- // TODO: properly namespace the routes e.g. bim.something- {- name: 'bim_defaults',- parent: 'root',- url: '/ifc_models/defaults/',- component: IFCIndexPageComponent- },- {- name: 'bim_show',- parent: 'root',- url: '/ifc_models/{model_id:[0-9]+}/',- component: IFCIndexPageComponent,- }-];--export function uiRouterIFCConfiguration(uiRouter:UIRouter) {- uiRouter.urlService.rules- .when(- new RegExp("^/projects/(.*)/ifc_models/defaults$"),- match => `/projects/${match[1]}/ifc_models/defaults/`- );-- uiRouter.urlService.rules- .when(- new RegExp("^/projects/(.*)/ifc_models/([0-9]+)$"),- match => `/projects/${match[1]}/ifc_models/${match[2]}/`- );-}+import {IFCViewerComponent} from './ifc-viewer/ifc-viewer.component';+import {IFC_ROUTES, uiRouterIFCConfiguration} from "core-app/modules/ifc_models/openproject-ifc-models.routes";+import {IfcViewerPageComponent} from "core-app/modules/ifc_models/pages/viewer/ifc-viewer-page.component";+import {IfcSplitPageComponent} from "core-app/modules/ifc_models/pages/split/ifc-split-page.component";+import {BimViewToggleDropdownDirective} from "core-app/modules/ifc_models/view-toggle/bim-view-toggle-dropdown.directive";+import {BimViewToggleComponent} from "core-app/modules/ifc_models/view-toggle/bim-view-toggle.component";@NgModule({imports: [@@ -75,7 +49,12 @@ export function uiRouterIFCConfiguration(uiRouter:UIRouter) {],declarations: [// Pages- IFCIndexPageComponent,+ IfcViewerPageComponent,+ IfcSplitPageComponent,++ // View selector+ BimViewToggleComponent,+ BimViewToggleDropdownDirective,IFCViewerComponent],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.tsnew file mode 100644index 00000000000..5e28914df7a--- /dev/null+++ b/frontend/src/app/modules/ifc_models/openproject-ifc-models.routes.ts@@ -0,0 +1,98 @@+// -- 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-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.+// +++import {Ng2StateDeclaration, UIRouter} from '@uirouter/angular';+import {IfcViewerPageComponent} from "core-app/modules/ifc_models/pages/viewer/ifc-viewer-page.component";+import {IfcSplitPageComponent} from "core-app/modules/ifc_models/pages/split/ifc-split-page.component";+import {ApplicationBaseComponent} from "core-app/modules/router/base/application-base.component";+import {IFCViewerComponent} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewer.component";++export const IFC_ROUTES:Ng2StateDeclaration[] = [+ {+ name: 'bim',+ parent: 'root',+ url: '/ifc_models',+ abstract: true,+ component: IfcViewerPageComponent+ },+ {+ name: 'bim.list',+ url: '/list',+ component: IfcViewerPageComponent,+ views: {+ right: { component: IfcSplitPageComponent }+ }+ },+ {+ name: 'bim.defaults',+ url: '/defaults',+ component: IfcViewerPageComponent,+ views: {+ left: { component: IFCViewerComponent }+ }+ },+ {+ name: 'bim.defaults.split',+ url: '/split',+ component: IfcViewerPageComponent,+ views: {+ left: { component: IFCViewerComponent },+ right: { component: IfcSplitPageComponent }+ }+ },+ {+ name: 'bim.show',+ url: '/{model_id:[0-9]+}',+ component: IfcViewerPageComponent,+ views: {+ left: { component: IfcViewerPageComponent }+ }+ },+ {+ name: 'bim.show.split',+ url: '/split',+ component: IfcViewerPageComponent,+ views: {+ left: { component: IFCViewerComponent },+ right: { component: IfcSplitPageComponent }+ }+ },+];++export function uiRouterIFCConfiguration(uiRouter:UIRouter) {+ uiRouter.urlService.rules+ .when(+ new RegExp("^/projects/(.*)/ifc_models/defaults$"),+ match => `/projects/${match[1]}/ifc_models/defaults/`+ );++ uiRouter.urlService.rules+ .when(+ new RegExp("^/projects/(.*)/ifc_models/([0-9]+)$"),+ match => `/projects/${match[1]}/ifc_models/${match[2]}/`+ );+}diff --git a/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.html b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.htmlnew file mode 100644index 00000000000..f79644d0a0e--- /dev/null+++ b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.html@@ -0,0 +1,4 @@+<wp-embedded-table [queryProps]="queryProps"+ [configuration]="configuration"+ [externalHeight]="false">+</wp-embedded-table>diff --git a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.sass b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.sasssimilarity index 72%rename from frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.sassrename to frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.sassindex 641b41b48a0..b5f8a537751 100644--- a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.sass+++ b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.sass@@ -4,15 +4,12 @@display: gridgrid-template-columns: 1fr 500pxgrid-template-rows: 60px calc(100% - 60px)- grid-template-areas: "header header" "ifc-model wp-list"+ grid-template-areas: "header header" "ifc-model"grid-column-gap: 10px.toolbar-containergrid-area: header- .ifc-view--view-table-container- grid-area: wp-list-.ifc-view--viewer-containergrid-area: ifc-modelposition: relativediff --git a/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.ts b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.tsnew file mode 100644index 00000000000..426917dac6a--- /dev/null+++ b/frontend/src/app/modules/ifc_models/pages/split/ifc-split-page.component.ts@@ -0,0 +1,52 @@+import {Component} 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";+import {WorkPackageTableConfigurationObject} from "core-components/wp-table/wp-table-configuration";+import { StateService } from '@uirouter/core';+import {GonService} from "core-app/modules/common/gon/gon.service";++@Component({+ templateUrl: './ifc-split-page.component.html',+ styleUrls: ['./ifc-split-page.component.sass']+})+export class IfcSplitPageComponent {+ public queryProps:{ [key:string]:any };+ public configuration:WorkPackageTableConfigurationObject = {+ actionsColumnEnabled: false,+ columnMenuEnabled: false,+ contextMenuEnabled: false,+ inlineCreateEnabled: false,+ withFilters: true,+ showFilterButton: false,+ isCardView: true+ };++ private filters:any[] = [];++ constructor(readonly state:StateService,+ readonly i18n:I18nService,+ readonly paths:PathHelperService,+ readonly currentProject:CurrentProjectService,+ readonly gon:GonService) {++ this.applyFilters();+ }++ private applyFilters() {+ // TODO: Limit to project+ this.filters.push({+ status: {+ operator: 'o',+ values: []+ }+ });++ this.queryProps = {+ 'columns[]': ['id', 'subject'],+ filters: JSON.stringify(this.filters),+ sortBy: JSON.stringify([['updatedAt', 'desc']]),+ showHierarchies: false+ };+ }+}diff --git a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.htmlsimilarity index 62%rename from frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.htmlrename to frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.htmlindex ee9654c642c..4c83bc538ef 100644--- a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.html+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html@@ -5,6 +5,9 @@</h2></div><ul class="toolbar-items">+ <li class="toolbar-item">+ <bim-view-toggle-button></bim-view-toggle-button>+ </li><li class="toolbar-item"*ngIf="manageAllowed"><a class="button"@@ -22,13 +25,15 @@</div></div>-<div class="ifc-view--viewer-container">- <ifc-viewer></ifc-viewer>-</div>+<div class="ifc-view--split-container">+ <div class="ifc-view--viewer-container"+ [ngClass]="{ '-active': viewerActive }"+ ui-view="left">+ </div>-<div class="ifc-view--table-container" wp-isolated-query-space>- <wp-embedded-table [queryProps]="queryProps"- [configuration]="configuration"- [externalHeight]="true">- </wp-embedded-table>+ <div class="ifc-view--table-container"+ [ngClass]="{ '-active': tableActive }"+ ui-view="right"+ wp-isolated-query-space>+ </div></div>diff --git a/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.sass b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.sassnew file mode 100644index 00000000000..9117c9a122c--- /dev/null+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.sass@@ -0,0 +1,25 @@+*:host+ height: 100%+ overflow: hidden+ display: grid+ grid-template-columns: 1fr 500px+ grid-template-rows: 60px calc(100% - 60px)+ grid-template-areas: "header header" "ifc-model ifc-model"+ grid-column-gap: 10px++ .toolbar-container+ grid-area: header++ .ifc-view--split-container+ grid-area: ifc-model+ position: relative+ overflow: hidden+ display: flex++ .ifc-view--viewer-container,+ .ifc-view--table-container+ display: none++ &.-active+ display: block+ flex: 1diff --git a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.tssimilarity index 64%rename from frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.tsrename to frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.tsindex fd85ff7b7bb..4470be72bc0 100644--- a/frontend/src/app/modules/ifc_models/pages/index/ifc-index-page.component.ts+++ b/frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts@@ -7,10 +7,10 @@ import { StateService } from '@uirouter/core';import {GonService} from "core-app/modules/common/gon/gon.service";@Component({- templateUrl: './ifc-index-page.component.html',- styleUrls: ['./ifc-index-page.component.sass']+ templateUrl: './ifc-viewer-page.component.html',+ styleUrls: ['./ifc-viewer-page.component.sass']})-export class IFCIndexPageComponent {+export class IfcViewerPageComponent {public text = {title: this.i18n.t('js.ifc_models.models.default'),manage: this.i18n.t('js.ifc_models.models.manage'),@@ -18,26 +18,12 @@ export class IFCIndexPageComponent {edit: this.i18n.t('js.button_edit'),areYouSure: this.i18n.t('js.text_are_you_sure')};- public queryProps:{ [key:string]:any };- public configuration:WorkPackageTableConfigurationObject = {- actionsColumnEnabled: false,- columnMenuEnabled: false,- contextMenuEnabled: false,- inlineCreateEnabled: false,- withFilters: true,- showFilterButton: false,- isCardView: true- };-- private filters:any[] = [];constructor(readonly state:StateService,readonly i18n:I18nService,readonly paths:PathHelperService,readonly currentProject:CurrentProjectService,readonly gon:GonService) {-- this.applyFilters();}public get title() {@@ -56,25 +42,16 @@ export class IFCIndexPageComponent {return this.paths.ifcModelsPath(this.projectIdentifier);}- public get manageAllowed() {- return this.gonIFC.permissions.manage;+ public get viewerActive() {+ return this.state.includes('bim.defaults') || this.state.includes('bim.show');}- private applyFilters() {- // TODO: Limit to project- this.filters.push({- status: {- operator: 'o',- values: []- }- });+ public get tableActive() {+ return this.state.includes('bim.list') || this.state.includes('bim.*.split');+ }- this.queryProps = {- 'columns[]': ['id', 'subject'],- filters: JSON.stringify(this.filters),- sortBy: JSON.stringify([['updatedAt', 'desc']]),- showHierarchies: false- };+ public get manageAllowed() {+ return this.gonIFC.permissions.manage;}private get gonIFC() {diff --git a/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle-dropdown.directive.ts b/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle-dropdown.directive.tsnew file mode 100644index 00000000000..4244697fae1--- /dev/null+++ b/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle-dropdown.directive.ts@@ -0,0 +1,90 @@+//-- 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 {OPContextMenuService} from "core-components/op-context-menu/op-context-menu.service";+import {Directive, ElementRef} from "@angular/core";+import {OpContextMenuTrigger} from "core-components/op-context-menu/handlers/op-context-menu-trigger.directive";+import {I18nService} from "core-app/modules/common/i18n/i18n.service";+import {+ bimListViewIdentifier,+ bimSplitViewIdentifier,+ bimViewerViewIdentifier+} from "core-app/modules/ifc_models/view-toggle/bim-view-toggle.component";+import {StateService} from "@uirouter/core";++@Directive({+ selector: '[bimViewDropdown]'+})+export class BimViewToggleDropdownDirective extends OpContextMenuTrigger {+ constructor(readonly elementRef:ElementRef,+ readonly opContextMenu:OPContextMenuService,+ readonly I18n:I18nService,+ readonly state:StateService) {++ super(elementRef, opContextMenu);+ }++ protected open(evt:JQuery.TriggeredEvent) {+ this.buildItems();+ this.opContextMenu.show(this, evt);+ }++ public get locals() {+ return {+ items: this.items,+ contextMenuId: 'bim-view-context-menu'+ };+ }++ private buildItems() {+ this.items = [bimViewerViewIdentifier, bimListViewIdentifier, bimSplitViewIdentifier]+ .map(key => {+ return {+ // Card View+ linkText: this.I18n.t('js.ifc_models.views.' + key),+ onClick: (evt:any) => {+ switch (key) {+ case bimListViewIdentifier:+ this.state.go('bim.list');+ break;+ case bimViewerViewIdentifier:+ // TODO use correct route+ this.state.go('bim.defaults');+ break;+ case bimSplitViewIdentifier:+ this.state.go('bim.defaults.split');+ break;+ }++ return true;+ }+ };+ });+ }+}+diff --git a/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle.component.ts b/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle.component.tsnew file mode 100644index 00000000000..23d4399873b--- /dev/null+++ b/frontend/src/app/modules/ifc_models/view-toggle/bim-view-toggle.component.ts@@ -0,0 +1,100 @@+// -- 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 {ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';+import {I18nService} from 'core-app/modules/common/i18n/i18n.service';+import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";+import {+ WorkPackageViewDisplayRepresentationService,+ wpDisplayCardRepresentation,+ wpDisplayListRepresentation, wpDisplayRepresentation+} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-display-representation.service";+import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";+import {WorkPackageViewTimelineService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-timeline.service";+import {combineLatest} from "rxjs";+import {StateService, TransitionService} from "@uirouter/core";+++export const bimListViewIdentifier = 'list';+export const bimViewerViewIdentifier = 'viewer';+export const bimSplitViewIdentifier = 'split';++@Component({+ template: `+ <button class="button"+ id="bim-view-toggle-button"+ bimViewDropdown>+ <span class="button--text"+ aria-hidden="true"+ [textContent]="text[view]">+ </span>+ <op-icon icon-classes="button--icon icon-small icon-pulldown"></op-icon>+ </button>+`,+ changeDetection: ChangeDetectionStrategy.OnPush,+ selector: 'bim-view-toggle-button',+})+export class BimViewToggleComponent implements OnInit, OnDestroy {+ public view:string;++ public text:any = {+ list: this.I18n.t('js.ifc_models.views.list'),+ viewer: this.I18n.t('js.ifc_models.views.viewer'),+ split: this.I18n.t('js.ifc_models.views.split')+ };++ private transitionFn:Function;++ constructor(readonly I18n:I18nService,+ readonly transitions:TransitionService,+ readonly state:StateService,+ readonly cdRef:ChangeDetectorRef) {+ }++ ngOnInit() {+ this.detectView();++ this.transitionFn = this.transitions.onSuccess({}, (transition) => {+ this.detectView();+ });+ }++ private detectView() {+ if (this.state.current.name === 'bim.list') {+ this.view = bimListViewIdentifier;+ } else if (this.state.includes('bim.**.split')) {+ this.view = bimSplitViewIdentifier;+ } else {+ this.view = bimViewerViewIdentifier;+ }+ }++ ngOnDestroy() {+ this.transitionFn();+ }+}diff --git a/modules/ifc_models/config/locales/js-en.yml b/modules/ifc_models/config/locales/js-en.ymlindex 464a53bddb2..3db64d6b520 100644--- a/modules/ifc_models/config/locales/js-en.yml+++ b/modules/ifc_models/config/locales/js-en.yml@@ -4,3 +4,7 @@ en:models:default: 'Default IFC models'manage: 'Manage models'+ views:+ list: 'List only'+ viewer: 'Viewer only'+ split: 'Viewer and list'diff --git a/modules/ifc_models/config/routes.rb b/modules/ifc_models/config/routes.rbindex 34cd6a60570..5ed9d3a6d92 100644--- a/modules/ifc_models/config/routes.rb+++ b/modules/ifc_models/config/routes.rb@@ -31,9 +31,14 @@OpenProject::Application.routes.draw doscope '', as: 'ifc_models' doscope 'projects/:project_id', as: 'project' do- resources :ifc_models, controller: 'ifc_models/ifc_models' do+ resources :ifc_models, except: [:show], controller: 'ifc_models/ifc_models' docollection do- get 'defaults'+ get 'defaults(/*state)', action: :defaults+ get 'list(/*state)', action: :defaults+ end++ member do+ get 'show(/*state)', action: :showendendend