From e87cadd1a6ecd49fb32e1a5ef9853b8f47cd62f9 Mon Sep 17 00:00:00 2001 From: Henriette Darge Date: Fri, 12 Jun 2020 15:21:30 +0200 Subject: [PATCH] Pass the baseRoute as a parameter along. This is needed to navigate back to the correct view after deleting a WP coming from the BIM page --- .../keep-tab/keep-tab.service.ts | 6 ++++- .../openproject-ifc-models.routes.ts | 1 + .../back-routing/back-routing.service.ts | 10 ++++--- .../routing/split-view-routes.template.ts | 4 +++ .../bim/spec/features/bim_navigation_spec.rb | 26 ++++++++++++++++--- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts index cbd2d6968a..275d0f8f9b 100644 --- a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts +++ b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts @@ -68,8 +68,12 @@ export class KeepTabService { return 'work-packages.partitioned.list.details.' + this.currentDetailsTab; } + public get currentDetailsSubState():string { + return '.details.' + this.currentDetailsTab; + } + public isDetailsState(stateName:string) { - return stateName === 'work-packages.partitioned.list.details'; + return !!stateName && stateName.includes('.details'); } public get currentShowTab():string { diff --git a/frontend/src/app/modules/bim/ifc_models/openproject-ifc-models.routes.ts b/frontend/src/app/modules/bim/ifc_models/openproject-ifc-models.routes.ts index eec1ee4e38..0e269e6bcc 100644 --- a/frontend/src/app/modules/bim/ifc_models/openproject-ifc-models.routes.ts +++ b/frontend/src/app/modules/bim/ifc_models/openproject-ifc-models.routes.ts @@ -72,6 +72,7 @@ export const IFC_ROUTES:Ng2StateDeclaration[] = [ name: 'bim.partitioned.split', url: '/split', data: { + baseRoute: 'bim.partitioned.split', partition: '-split', newRoute: 'bim.partitioned.split.new', bodyClasses: 'router--work-packages-partitioned-split-view' diff --git a/frontend/src/app/modules/common/back-routing/back-routing.service.ts b/frontend/src/app/modules/common/back-routing/back-routing.service.ts index a6b2493364..9cd9850453 100644 --- a/frontend/src/app/modules/common/back-routing/back-routing.service.ts +++ b/frontend/src/app/modules/common/back-routing/back-routing.service.ts @@ -35,6 +35,7 @@ interface BackRouteOptions { name:string; params:{}; parent:string; + baseRoute:string; } @Injectable({ providedIn: 'root' }) @@ -50,7 +51,7 @@ export class BackRoutingService { public goBack(preferListOverSplit:boolean = false) { // Default: back to list // When coming from a deep link or a create form - const baseRoute = this.$state.current.data.baseRoute || 'work-packages.partitioned.list'; + const baseRoute = this.backRoute?.baseRoute || this.$state.current.data.baseRoute || 'work-packages.partitioned.list'; if (!this.backRoute || this.backRoute.name.includes('new')) { this.$state.go(baseRoute, this.$state.params); @@ -59,7 +60,7 @@ export class BackRoutingService { if (preferListOverSplit) { this.$state.go(baseRoute, this.$state.params); } else { - this.$state.go(this.keepTab.currentDetailsState, this.$state.params); + this.$state.go(baseRoute + this.keepTab.currentDetailsSubState, this.$state.params); } } else { this.$state.go(this.backRoute.name, this.backRoute.params); @@ -82,7 +83,10 @@ export class BackRoutingService { toState.data && fromState.data.parent !== toState.data.parent) { const paramsFromCopy = { ...transition.params('from') }; - this.backRoute = { name: fromState.name, params: paramsFromCopy, parent: fromState.data.parent }; + this.backRoute = { name: fromState.name, + params: paramsFromCopy, + parent: fromState.data.parent, + baseRoute: fromState.data.baseRoute }; } } 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 6d5ac1e1d9..c77d5423ef 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 @@ -83,6 +83,7 @@ export function makeSplitViewRoutes(baseRoute:string, url: '/overview', component: WorkPackageOverviewTabComponent, data: { + baseRoute: baseRoute, menuItem: menuItemClass, parent: baseRoute + '.details' } @@ -92,6 +93,7 @@ export function makeSplitViewRoutes(baseRoute:string, url: '/activity', component: WorkPackageActivityTabComponent, data: { + baseRoute: baseRoute, menuItem: menuItemClass, parent: baseRoute + '.details' } @@ -101,6 +103,7 @@ export function makeSplitViewRoutes(baseRoute:string, url: '/relations', component: WorkPackageRelationsTabComponent, data: { + baseRoute: baseRoute, menuItem: menuItemClass, parent: baseRoute + '.details' } @@ -110,6 +113,7 @@ export function makeSplitViewRoutes(baseRoute:string, url: '/watchers', component: WorkPackageWatchersTabComponent, data: { + baseRoute: baseRoute, menuItem: menuItemClass, parent: baseRoute + '.details' } diff --git a/modules/bim/spec/features/bim_navigation_spec.rb b/modules/bim/spec/features/bim_navigation_spec.rb index 1425cd9959..e91056a49b 100644 --- a/modules/bim/spec/features/bim_navigation_spec.rb +++ b/modules/bim/spec/features/bim_navigation_spec.rb @@ -34,7 +34,7 @@ describe 'BIM navigation spec', js: true do let(:project) { FactoryBot.create :project, enabled_module_names: [:bim, :work_package_tracking] } let!(:work_package) { FactoryBot.create(:work_package, project: project) } - let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models view_work_packages]) } + let(:role) { FactoryBot.create(:role, permissions: %i[view_ifc_models manage_ifc_models view_work_packages delete_work_packages]) } let(:user) do FactoryBot.create :user, @@ -52,6 +52,7 @@ describe 'BIM navigation spec', let(:details_view) { ::Pages::BcfDetailsPage.new(work_package, project) } let(:full_view) { Pages::FullWorkPackage.new(work_package) } let(:model_tree) { ::Components::XeokitModelTree.new } + let(:destroy_modal) { Components::WorkPackages::DestroyModal.new } shared_examples 'can switch from split to viewer to list-only' do before do @@ -65,9 +66,7 @@ describe 'BIM navigation spec', login_as(user) model_page.visit! model_page.finished_loading - end - 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 @@ -75,7 +74,9 @@ describe 'BIM navigation spec', model_tree.sidebar_shows_viewer_menu true expect(page).to have_selector('.wp-cards-container') card_view.expect_work_package_listed work_package + end + it 'can switch between the different view modes' do # Go to single view card_view.open_full_screen_by_details(work_package) @@ -119,6 +120,25 @@ describe 'BIM navigation spec', details_view.close details_view.expect_closed end + + it 'after deleting an WP in full view it returns to the model and list view (see #33317)' do + # Go to full single view + card_view.open_full_screen_by_details(work_package) + details_view.switch_to_fullscreen + full_view.expect_tab 'Activity' + + # Delete via the context menu + find('#action-show-more-dropdown-menu .button').click + find('.menu-item', text: 'Delete').click + + destroy_modal.expect_listed(work_package) + destroy_modal.confirm_deletion + + # Expect to return to the start page with closed details view and delete WP + model_page.model_viewer_visible true + details_view.expect_closed + card_view.expect_work_package_not_listed work_package + end end end