From a568365344aa3dd1ce1e091e6f936da0c50a2906 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 31 Mar 2021 10:25:01 +0200 Subject: [PATCH] MOBILE-3639 siteplugins: Fix module routes --- .../classes/handlers/user-handler.ts | 2 +- .../only-title-block/only-title-block.ts | 2 +- .../plugin-content/plugin-content.ts | 2 +- .../directives/call-ws-new-content.ts | 2 +- .../siteplugins/directives/new-content.ts | 2 +- .../siteplugins/siteplugins-lazy.module.ts | 32 ------------------- .../siteplugins/siteplugins.module.ts | 13 ++++++-- 7 files changed, 15 insertions(+), 40 deletions(-) delete mode 100644 src/core/features/siteplugins/siteplugins-lazy.module.ts diff --git a/src/core/features/siteplugins/classes/handlers/user-handler.ts b/src/core/features/siteplugins/classes/handlers/user-handler.ts index 315e198da..12e48e214 100644 --- a/src/core/features/siteplugins/classes/handlers/user-handler.ts +++ b/src/core/features/siteplugins/classes/handlers/user-handler.ts @@ -100,7 +100,7 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle const hash = Md5.hashAsciiStr(JSON.stringify(args)); CoreNavigator.navigateToSitePath( - `siteplugins/${this.plugin.component}/${this.handlerSchema.method}/${hash}`, + `siteplugins/content/${this.plugin.component}/${this.handlerSchema.method}/${hash}`, { params: { title: this.title, diff --git a/src/core/features/siteplugins/components/only-title-block/only-title-block.ts b/src/core/features/siteplugins/components/only-title-block/only-title-block.ts index 742c392d3..292b36d92 100644 --- a/src/core/features/siteplugins/components/only-title-block/only-title-block.ts +++ b/src/core/features/siteplugins/components/only-title-block/only-title-block.ts @@ -60,7 +60,7 @@ export class CoreSitePluginsOnlyTitleBlockComponent extends CoreBlockBaseCompon const hash = Md5.hashAsciiStr(JSON.stringify(args)); CoreNavigator.navigateToSitePath( - `siteplugins/${handler.plugin.component}/${handler.handlerSchema.method}/${hash}`, + `siteplugins/content/${handler.plugin.component}/${handler.handlerSchema.method}/${hash}`, { params: { title: this.title, diff --git a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts index 24187a1a7..91b3bb2ce 100644 --- a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts @@ -153,7 +153,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { args = args || {}; const hash = Md5.hashAsciiStr(JSON.stringify(args)); - CoreNavigator.navigateToSitePath(`siteplugins/${component}/${method}/${hash}`, { + CoreNavigator.navigateToSitePath(`siteplugins/content/${component}/${method}/${hash}`, { params: { title, args, diff --git a/src/core/features/siteplugins/directives/call-ws-new-content.ts b/src/core/features/siteplugins/directives/call-ws-new-content.ts index 54c773fd9..f76432877 100644 --- a/src/core/features/siteplugins/directives/call-ws-new-content.ts +++ b/src/core/features/siteplugins/directives/call-ws-new-content.ts @@ -103,7 +103,7 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal const method = this.method || this.parentContent?.method; const hash = Md5.hashAsciiStr(JSON.stringify(args)); - CoreNavigator.navigateToSitePath(`siteplugins/${component}/${method}/${hash}`, { + CoreNavigator.navigateToSitePath(`siteplugins/content/${component}/${method}/${hash}`, { params: { title: this.title || this.parentContent?.pageTitle, args, diff --git a/src/core/features/siteplugins/directives/new-content.ts b/src/core/features/siteplugins/directives/new-content.ts index 6faee7123..02a9c7909 100644 --- a/src/core/features/siteplugins/directives/new-content.ts +++ b/src/core/features/siteplugins/directives/new-content.ts @@ -100,7 +100,7 @@ export class CoreSitePluginsNewContentDirective implements OnInit { const method = this.method || this.parentContent?.method; const hash = Md5.hashAsciiStr(JSON.stringify(args)); - CoreNavigator.navigateToSitePath(`siteplugins/${component}/${method}/${hash}`, { + CoreNavigator.navigateToSitePath(`siteplugins/content/${component}/${method}/${hash}`, { params: { title: this.title || this.parentContent?.pageTitle, args, diff --git a/src/core/features/siteplugins/siteplugins-lazy.module.ts b/src/core/features/siteplugins/siteplugins-lazy.module.ts deleted file mode 100644 index 7b7e4a3dd..000000000 --- a/src/core/features/siteplugins/siteplugins-lazy.module.ts +++ /dev/null @@ -1,32 +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 { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -const routes: Routes = [ - { - path: 'module/:courseId/:cmId', - loadChildren: () => import('./pages/module-index/module-index.module').then( m => m.CoreSitePluginsModuleIndexPageModule), - }, - { - path: ':component/:method/:hash', - loadChildren: () => import('./pages/plugin-page/plugin-page.module').then( m => m.CoreSitePluginsPluginPageModule), - }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], -}) -export class CoreSitePluginsLazyModule {} diff --git a/src/core/features/siteplugins/siteplugins.module.ts b/src/core/features/siteplugins/siteplugins.module.ts index 730d504e2..7f15ec693 100644 --- a/src/core/features/siteplugins/siteplugins.module.ts +++ b/src/core/features/siteplugins/siteplugins.module.ts @@ -23,8 +23,8 @@ import { CoreSitePluginsHelper } from './services/siteplugins-helper'; const routes: Routes = [ { - path: 'siteplugins', - loadChildren: () => import('@features/siteplugins/siteplugins-lazy.module').then(m => m.CoreSitePluginsLazyModule), + path: 'siteplugins/content/:component/:method/:hash', + loadChildren: () => import('./pages/plugin-page/plugin-page.module').then( m => m.CoreSitePluginsPluginPageModule), }, ]; @@ -36,9 +36,16 @@ const courseIndexRoutes: Routes = [ }, ]; +const moduleRoutes: Routes = [ + { + path: 'siteplugins/module/:courseId/:cmId', + loadChildren: () => import('./pages/module-index/module-index.module').then( m => m.CoreSitePluginsModuleIndexPageModule), + }, +]; + @NgModule({ imports: [ - CoreMainMenuTabRoutingModule.forChild(routes), + CoreMainMenuTabRoutingModule.forChild(moduleRoutes.concat(routes)), CoreCourseIndexRoutingModule.forChild({ children: courseIndexRoutes }), CoreMainMenuHomeRoutingModule.forChild({ children: routes }), CoreSitePluginsComponentsModule,