MOBILE-3592 routes: Allow add siblings to any main menu tab
parent
36d03d27c5
commit
186593b09f
|
@ -12,23 +12,33 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'root', // Fake "hash".
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: ':hash',
|
||||
loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule),
|
||||
},
|
||||
];
|
||||
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
return [
|
||||
{
|
||||
path: ':hash',
|
||||
loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule),
|
||||
},
|
||||
...buildTabMainRoutes(injector, {
|
||||
redirectTo: 'root', // Fake "hash".
|
||||
pathMatch: 'full',
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ROUTES,
|
||||
multi: true,
|
||||
deps: [Injector],
|
||||
useFactory: buildRoutes,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AddonPrivateFilesLazyModule {}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
import { Route, Routes } from '@angular/router';
|
||||
|
||||
import { ModuleRoutes, resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
export const MAIN_MENU_TAB_ROUTES = new InjectionToken('MAIN_MENU_TAB_ROUTES');
|
||||
|
||||
export function buildTabMainRoutes(injector: Injector, mainRoute: Route): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_TAB_ROUTES);
|
||||
|
||||
mainRoute.path = mainRoute.path || '';
|
||||
mainRoute.children = mainRoute.children || [];
|
||||
mainRoute.children.concat(routes.children);
|
||||
|
||||
return [
|
||||
mainRoute,
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule()
|
||||
export class CoreMainMenuTabRoutingModule {
|
||||
|
||||
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuTabRoutingModule> {
|
||||
return {
|
||||
ngModule: CoreMainMenuTabRoutingModule,
|
||||
providers: [
|
||||
{ provide: MAIN_MENU_TAB_ROUTES, multi: true, useValue: routes },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -24,16 +24,17 @@ import { CoreDirectivesModule } from '@directives/directives.module';
|
|||
|
||||
import { CoreMainMenuHomePage } from './home';
|
||||
import { MAIN_MENU_HOME_ROUTES } from './home-routing.module';
|
||||
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES);
|
||||
|
||||
return [
|
||||
{
|
||||
...buildTabMainRoutes(injector, {
|
||||
path: '',
|
||||
component: CoreMainMenuHomePage,
|
||||
children: routes.children,
|
||||
},
|
||||
}),
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
|
||||
|
||||
import { ModuleRoutes } from '@/app/app-routing.module';
|
||||
|
||||
export const MAIN_MENU_MORE_ROUTES = new InjectionToken('MAIN_MENU_MORE_ROUTES');
|
||||
|
||||
@NgModule()
|
||||
export class CoreMainMenuMoreRoutingModule {
|
||||
|
||||
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuMoreRoutingModule> {
|
||||
return {
|
||||
ngModule: CoreMainMenuMoreRoutingModule,
|
||||
providers: [
|
||||
{ provide: MAIN_MENU_MORE_ROUTES, multi: true, useValue: routes },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -14,29 +14,14 @@
|
|||
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { RouterModule, ROUTES } from '@angular/router';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
import { CoreComponentsModule } from '@components/components.module';
|
||||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
|
||||
import { CoreMainMenuMorePage } from './more';
|
||||
import { MAIN_MENU_MORE_ROUTES } from './more-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
const routes = resolveModuleRoutes(injector, MAIN_MENU_MORE_ROUTES);
|
||||
|
||||
return [
|
||||
{
|
||||
path: '',
|
||||
component: CoreMainMenuMorePage,
|
||||
children: routes.children,
|
||||
},
|
||||
...routes.siblings,
|
||||
];
|
||||
}
|
||||
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -47,7 +32,14 @@ function buildRoutes(injector: Injector): Routes {
|
|||
CoreDirectivesModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
|
||||
{
|
||||
provide: ROUTES,
|
||||
multi: true,
|
||||
deps: [Injector],
|
||||
useFactory: (injector: Injector) => buildTabMainRoutes(injector, {
|
||||
component: CoreMainMenuMorePage,
|
||||
}),
|
||||
},
|
||||
],
|
||||
declarations: [
|
||||
CoreMainMenuMorePage,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { APP_INITIALIZER, NgModule } from '@angular/core';
|
|||
import { Routes } from '@angular/router';
|
||||
|
||||
import { AppRoutingModule } from '@/app/app-routing.module';
|
||||
import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module';
|
||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
|
||||
import { CoreSettingsHelperProvider } from './services/settings-helper';
|
||||
|
||||
|
@ -41,7 +41,7 @@ const mainMenuMoreRoutes: Routes = [
|
|||
@NgModule({
|
||||
imports: [
|
||||
AppRoutingModule.forChild(appRoutes),
|
||||
CoreMainMenuMoreRoutingModule.forChild({ siblings: mainMenuMoreRoutes }),
|
||||
CoreMainMenuTabRoutingModule.forChild({ siblings: mainMenuMoreRoutes }),
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
|
|
|
@ -12,31 +12,42 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'index',
|
||||
loadChildren: () => import('@features/tag/pages/index/index.page.module').then(m => m.CoreTagIndexPageModule),
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule),
|
||||
},
|
||||
{
|
||||
path: 'index-area',
|
||||
loadChildren: () => import('@features/tag/pages/index-area/index-area.page.module').then(m => m.CoreTagIndexAreaPageModule),
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'search',
|
||||
pathMatch: 'full',
|
||||
},
|
||||
];
|
||||
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
return [
|
||||
{
|
||||
path: 'index',
|
||||
loadChildren: () => import('@features/tag/pages/index/index.page.module').then(m => m.CoreTagIndexPageModule),
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule),
|
||||
},
|
||||
{
|
||||
path: 'index-area',
|
||||
loadChildren: () =>
|
||||
import('@features/tag/pages/index-area/index-area.page.module').then(m => m.CoreTagIndexAreaPageModule),
|
||||
},
|
||||
...buildTabMainRoutes(injector, {
|
||||
redirectTo: 'search',
|
||||
pathMatch: 'full',
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ROUTES,
|
||||
multi: true,
|
||||
deps: [Injector],
|
||||
useFactory: buildRoutes,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class CoreTagLazyModule { }
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module';
|
||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/database/user';
|
||||
import { CoreUserComponentsModule } from './components/components.module';
|
||||
|
@ -37,7 +37,7 @@ const routes: Routes = [
|
|||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreMainMenuMoreRoutingModule.forChild({ siblings: routes }),
|
||||
CoreMainMenuTabRoutingModule.forChild({ siblings: routes }),
|
||||
CoreUserComponentsModule,
|
||||
],
|
||||
providers: [
|
||||
|
|
Loading…
Reference in New Issue