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

Make new split view use generic route template

Oliver Günther84546b76044e
diff --git a/frontend/src/app/components/wp-new/wp-create.component.ts b/frontend/src/app/components/wp-new/wp-create.component.ts
index 9b460fc5b03..2daffc839cd 100644
--- a/frontend/src/app/components/wp-new/wp-create.component.ts
+++ b/frontend/src/app/components/wp-new/wp-create.component.ts
@@ -47,7 +47,7 @@ import {WorkPackageNotificationService} from "core-app/modules/work_packages/not
export abstract class WorkPackageCreateComponent implements OnInit, OnDestroy {
public successState:string;
- public cancelState:string = 'work-packages.list';
+ public cancelState:string = this.$state.current.data.baseRoute;
public newWorkPackage:WorkPackageResource;
public parentWorkPackage:WorkPackageResource;
public change:WorkPackageChangeset;
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.ts
index 2450ca05f0e..41f01f86b63 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
@@ -35,5 +35,5 @@ import {ChangeDetectionStrategy, Component} from '@angular/core';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WorkPackageNewSplitViewComponent extends WorkPackageCreateComponent {
- public successState:string = 'work-packages.partitioned.list.details';
+ public successState:string = this.$state.current.data.baseRoute + '.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.ts
index 14513c980ed..93955d7fac5 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
@@ -37,8 +37,8 @@ import {IFCViewerService} from "core-app/modules/ifc_models/ifc-viewer/ifc-viewe
templateUrl: './bcf-new-split.component.html'
})
export class BCFNewSplitComponent extends WorkPackageCreateComponent {
- public successState:string = 'bim.partitioned.split.details';
- public cancelState:string = 'bim.partitioned.split';
+ public successState:string = '^.details';
+ public cancelState:string = '^';
@InjectField()
readonly viewer:IFCViewerService;
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
deleted file mode 100644
index f142880afc7..00000000000
--- a/frontend/src/app/modules/ifc_models/bcf/single-view/bcf-single-view.component.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-// -- 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/openproject-ifc-models.module.ts b/frontend/src/app/modules/ifc_models/openproject-ifc-models.module.ts
index c110c01c311..f03954e28e8 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
@@ -37,7 +37,6 @@ 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";
import {BCFNewSplitComponent} from "core-app/modules/ifc_models/bcf/new-split/bcf-new-split.component";
import {BcfListContainerComponent} from "core-app/modules/ifc_models/bcf/list-container/bcf-list-container.component";
@@ -67,7 +66,6 @@ import {BcfListContainerComponent} from "core-app/modules/ifc_models/bcf/list-co
BimViewToggleButtonComponent,
BimViewToggleDropdownDirective,
- BcfSingleViewComponent,
BCFNewSplitComponent,
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.ts
index 027c77fdcd9..da1c889675b 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
@@ -30,11 +30,9 @@ import {IFCViewerPageComponent} from "core-app/modules/ifc_models/pages/viewer/i
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";
-import {BCFNewSplitComponent} from "core-app/modules/ifc_models/bcf/new-split/bcf-new-split.component";
import {BcfListContainerComponent} from "core-app/modules/ifc_models/bcf/list-container/bcf-list-container.component";
-import {menuItemClass} from "core-app/modules/work_packages/routing/work-packages-routes";
+import {WorkPackageSplitViewComponent} from "core-app/modules/work_packages/routing/wp-split-view/wp-split-view.component";
export const IFC_ROUTES:Ng2StateDeclaration[] = [
@@ -99,29 +97,13 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [
...makeSplitViewRoutes(
'bim.partitioned.list',
undefined,
- BcfSingleViewComponent
+ WorkPackageSplitViewComponent
),
// BCF single view for split
...makeSplitViewRoutes(
'bim.partitioned.split',
undefined,
- BcfSingleViewComponent
+ WorkPackageSplitViewComponent
),
- {
- name: 'bim.partitioned.split.new',
- url: '/new?{type:[0-9]+}',
- reloadOnSearch: false,
- data: {
- partition: '-split',
- allowMovingInEditMode: true,
- bodyClasses: 'router--work-packages-partitioned-split-view-new',
- parent: 'bim.partitioned.split'
- },
- views: {
- // Retarget and by that override the grandparent views
- // https://ui-router.github.io/guide/views#relative-parent-state
- 'content-right@^.^': {component: BCFNewSplitComponent}
- }
- },
];
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 c85996ffc84..4f9a8d2e553 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
@@ -45,7 +45,7 @@ export class IFCViewerPageComponent extends PartitionedQuerySpacePageComponent {
{
component: WorkPackageCreateButtonComponent,
inputs: {
- stateName: "bim.partitioned.split.new",
+ stateName: ".new",
allowed: ['work_packages.createWorkPackage', 'work_package.copy']
}
},
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 d497f192d55..e8edcd07b63 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
@@ -509,7 +509,8 @@ import {WorkPackageSettingsButtonComponent} from "core-components/wp-buttons/wp-
WorkPackageCreateButtonComponent,
WorkPackageTypeStatusComponent,
WorkPackageEditActionsBarComponent,
- WorkPackageSingleViewComponent
+ WorkPackageSingleViewComponent,
+ WorkPackageSplitViewComponent
]
})
export class OpenprojectWorkPackagesModule {
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
index d565dd6c2d4..aa93277fd97 100644
--- 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
@@ -30,17 +30,8 @@ import {WorkPackageOverviewTabComponent} from 'core-components/wp-single-view-ta
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";
/**
@@ -60,11 +51,12 @@ import {ComponentType} from "@angular/cdk/overlay";
* 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
+ * @param showComponent The split view component to mount
*/
export function makeSplitViewRoutes(baseRoute:string,
menuItemClass:string|undefined,
- component:ComponentType<any>):Ng2StateDeclaration[] {
+ showComponent:ComponentType<any>,
+ newComponent:ComponentType<any> = WorkPackageNewSplitViewComponent):Ng2StateDeclaration[] {
return [
{
name: baseRoute + '.details',
@@ -74,12 +66,14 @@ export function makeSplitViewRoutes(baseRoute:string,
data: {
bodyClasses: 'router--work-packages-partitioned-split-view',
menuItem: menuItemClass,
+ // Remember the base route so we can route back to it anywhere
+ baseRoute: baseRoute,
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}
+ 'content-right@^.^': {component: showComponent}
}
},
{
@@ -118,5 +112,24 @@ export function makeSplitViewRoutes(baseRoute:string,
parent: baseRoute + '.details'
}
},
+ // Split create route
+ {
+ name: baseRoute + '.new',
+ url: '/new?{type:[0-9]+}',
+ reloadOnSearch: false,
+ data: {
+ partition: '-split',
+ allowMovingInEditMode: true,
+ bodyClasses: 'router--work-packages-partitioned-split-view-new',
+ // Remember the base route so we can route back to it anywhere
+ baseRoute: baseRoute,
+ parent: baseRoute
+ },
+ views: {
+ // Retarget and by that override the grandparent views
+ // https://ui-router.github.io/guide/views#relative-parent-state
+ 'content-right@^.^': {component: newComponent}
+ }
+ },
];
}
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 2427af61e44..83fef68753e 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
@@ -152,20 +152,6 @@ export const WORK_PACKAGES_ROUTES:Ng2StateDeclaration[] = [
menuItem: menuItemClass
}
},
- {
- name: 'work-packages.partitioned.list.new',
- url: '/create_new?type&parent_id',
- views: {
- 'content-right@^.^': { component: WorkPackageNewSplitViewComponent }
- },
- reloadOnSearch: false,
- data: {
- allowMovingInEditMode: true,
- bodyClasses: 'router--work-packages-partitioned-split-view-new',
- menuItem: menuItemClass,
- parent: 'work-packages.partitioned.list'
- },
- },
{
name: 'work-packages.partitioned.list.copy',
url: '/details/{copiedFromWorkPackageId:[0-9]+}/copy',
diff --git a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
index b53aad6fd0b..4bf34c600b3 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
@@ -49,6 +49,9 @@ import {WorkPackageNotificationService} from "core-app/modules/work_packages/not
})
export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase implements OnInit {
+ /** Reference to the base route e.g., work-packages.partitioned.list or bim.partitioned.split */
+ private baseRoute:string = this.$state.current.data.baseRoute;
+
constructor(public injector:Injector,
public states:States,
public firstRoute:FirstRouteService,
@@ -67,7 +70,7 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase imp
if (!focusedWP) {
// Focus on the work package if we're the first route
- const isFirstRoute = this.firstRoute.name === 'work-packages.partitioned.list.details.overview';
+ const isFirstRoute = this.firstRoute.name === `${this.baseRoute}.details.overview`;
const isSameID = this.firstRoute.params && wpId === this.firstRoute.params.workPackageI;
this.wpTableFocus.updateFocus(wpId, (isFirstRoute && isSameID));
} else {
@@ -84,7 +87,7 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase imp
)
.subscribe(newId => {
const idSame = wpId.toString() === newId.toString();
- if (!idSame && this.$state.includes('work-packages.partitioned.list.details')) {
+ if (!idSame && this.$state.includes(`${this.baseRoute}.details.overview`)) {
this.$state.go(
(this.$state.current.name as string),
{workPackageId: newId, focus: false}
@@ -95,7 +98,7 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase imp
public close() {
- this.$state.go('work-packages.partitioned.list', this.$state.params);
+ this.$state.go(this.baseRoute, this.$state.params);
}
public switchToFullscreen() {