From b3d380c9c2aa4b636df865af632cbb6fc4c2bd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 9 Feb 2021 11:35:36 +0100 Subject: [PATCH] MOBILE-3637 core: Fix some navigation to tabs problems --- src/addons/calendar/calendar.module.ts | 2 ++ src/addons/privatefiles/privatefiles.module.ts | 6 +++++- src/core/features/mainmenu/pages/more/more.ts | 16 ++++++++++++---- src/core/features/tag/components/list/list.ts | 2 +- src/core/features/tag/tag.module.ts | 2 ++ src/core/services/navigator.ts | 5 +++++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/addons/calendar/calendar.module.ts b/src/addons/calendar/calendar.module.ts index ab5cff1f0..1a2d8e16d 100644 --- a/src/addons/calendar/calendar.module.ts +++ b/src/addons/calendar/calendar.module.ts @@ -28,6 +28,7 @@ import { CALENDAR_SITE_SCHEMA } from './services/database/calendar'; import { CALENDAR_OFFLINE_SITE_SCHEMA } from './services/database/calendar-offline'; import { AddonCalendarComponentsModule } from './components/components.module'; import { AddonCalendar } from './services/calendar'; +import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; const mainMenuChildrenRoutes: Routes = [ { @@ -38,6 +39,7 @@ const mainMenuChildrenRoutes: Routes = [ @NgModule({ imports: [ + CoreMainMenuTabRoutingModule.forChild(mainMenuChildrenRoutes), CoreMainMenuRoutingModule.forChild({ children: mainMenuChildrenRoutes }), AddonCalendarComponentsModule, ], diff --git a/src/addons/privatefiles/privatefiles.module.ts b/src/addons/privatefiles/privatefiles.module.ts index 26e7073ab..3ea3bf1a7 100644 --- a/src/addons/privatefiles/privatefiles.module.ts +++ b/src/addons/privatefiles/privatefiles.module.ts @@ -18,6 +18,7 @@ import { Routes } from '@angular/router'; import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate'; import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module'; import { AddonPrivateFilesMainMenuHandler, AddonPrivateFilesMainMenuHandlerService } from './services/handlers/mainmenu'; +import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; const routes: Routes = [ { @@ -27,7 +28,10 @@ const routes: Routes = [ ]; @NgModule({ - imports: [CoreMainMenuRoutingModule.forChild({ children: routes })], + imports: [ + CoreMainMenuTabRoutingModule.forChild(routes), + CoreMainMenuRoutingModule.forChild({ children: routes }), + ], exports: [CoreMainMenuRoutingModule], providers: [ { diff --git a/src/core/features/mainmenu/pages/more/more.ts b/src/core/features/mainmenu/pages/more/more.ts index 8db63b6ec..e96ec3ff9 100644 --- a/src/core/features/mainmenu/pages/more/more.ts +++ b/src/core/features/mainmenu/pages/more/more.ts @@ -22,6 +22,7 @@ import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreMainMenuDelegate, CoreMainMenuHandlerData } from '../../services/mainmenu-delegate'; import { CoreMainMenu, CoreMainMenuCustomItem } from '../../services/mainmenu'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; +import { CoreNavigator } from '@services/navigator'; /** * Page that displays the main menu of the app. @@ -131,10 +132,12 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy { * Open a handler. * * @param handler Handler to open. + * @todo: use subPage? */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars openHandler(handler: CoreMainMenuHandlerData): void { - // @todo + const params = handler.pageParams; + + CoreNavigator.instance.navigateToSitePath(handler.page, { params }); } /** @@ -142,9 +145,11 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy { * * @param item Item to open. */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars openItem(item: CoreMainMenuCustomItem): void { - // @todo + // @todo CoreNavigator.instance.navigateToSitePath('CoreViewerIframePage', {title: item.label, url: item.url}); + + // eslint-disable-next-line no-console + console.error('openItem not implemented', item); } /** @@ -153,6 +158,9 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy { async scanQR(): Promise { // Scan for a QR code. // @todo + // eslint-disable-next-line no-console + console.error('scanQR not implemented'); + } /** diff --git a/src/core/features/tag/components/list/list.ts b/src/core/features/tag/components/list/list.ts index 97d4ce83b..23dac9ccf 100644 --- a/src/core/features/tag/components/list/list.ts +++ b/src/core/features/tag/components/list/list.ts @@ -41,7 +41,7 @@ export class CoreTagListComponent { }; // @todo: Check split view to navigate on the outlet if any. - CoreNavigator.instance.navigate('/tag/index', { params }); + CoreNavigator.instance.navigateToSitePath('/tag/index', { params, preferCurrentTab: false }); } } diff --git a/src/core/features/tag/tag.module.ts b/src/core/features/tag/tag.module.ts index 706f0a26c..fc46121d3 100644 --- a/src/core/features/tag/tag.module.ts +++ b/src/core/features/tag/tag.module.ts @@ -21,6 +21,7 @@ import { CoreTagMainMenuHandler, CoreTagMainMenuHandlerService } from './service import { CoreTagIndexLinkHandler } from './services/handlers/index-link'; import { CoreTagSearchLinkHandler } from './services/handlers/search-link'; import { CoreTagComponentsModule } from './components/components.module'; +import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; const routes: Routes = [ { @@ -31,6 +32,7 @@ const routes: Routes = [ @NgModule({ imports: [ + CoreMainMenuTabRoutingModule.forChild(routes), CoreMainMenuRoutingModule.forChild({ children: routes }), CoreTagComponentsModule, ], diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index 473807261..2e795d519 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -48,6 +48,7 @@ export type CoreNavigationOptions = { animated?: boolean; params?: Params; reset?: boolean; + preferCurrentTab?: boolean; // Default true. }; /** @@ -363,6 +364,10 @@ export class CoreNavigatorService { false, ); + if (options.preferCurrentTab === false && isMainMenuTab) { + return this.navigate(`/main/${path}`, options); + } + // Open the path within the current main tab. if (currentMainMenuTab && (!isMainMenuTab || pathRoot !== currentMainMenuTab)) { return this.navigate(`/main/${currentMainMenuTab}/${path}`, options);