MOBILE-3934 competency: Refactor routes
parent
ee8c9de101
commit
c549e733fb
|
@ -17,7 +17,7 @@ import { CoreBlockHandlerData } from '@features/block/services/block-delegate';
|
|||
import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block';
|
||||
import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Block handler.
|
||||
|
@ -38,7 +38,7 @@ export class AddonBlockLearningPlansHandlerService extends CoreBlockBaseHandler
|
|||
title: 'addon.block_learningplans.pluginname',
|
||||
class: 'addon-block-learning-plans',
|
||||
component: CoreBlockOnlyTitleComponent,
|
||||
link: ADDON_COMPETENCY_MAIN_PAGE_NAME,
|
||||
link: ADDON_COMPETENCY_LEARNING_PLANS_PAGE,
|
||||
navOptions: {
|
||||
preferCurrentTab: false,
|
||||
},
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
|
||||
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
|
||||
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
|
@ -31,4 +31,4 @@ const routes: Routes = [
|
|||
AddonCompetencyCourseCompetenciesPageModule,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyCourseLazyModule {}
|
||||
export class AddonCompetencyCourseContentsLazyModule {}
|
|
@ -0,0 +1,72 @@
|
|||
// (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';
|
||||
|
||||
import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page';
|
||||
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page';
|
||||
import { ADDON_COMPETENCY_SUMMARY_PAGE } from './competency.module';
|
||||
import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module';
|
||||
import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
|
||||
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
|
||||
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
|
||||
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies.page';
|
||||
import { conditionalRoutes } from '@/app/app-routing.module';
|
||||
import { CoreScreen } from '@services/screen';
|
||||
import { AddonCompetencyCompetenciesPageModule } from './pages/competencies/competencies.module';
|
||||
|
||||
const mobileRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: AddonCompetencyCourseCompetenciesPage,
|
||||
},
|
||||
{
|
||||
path: ':competencyId',
|
||||
component: AddonCompetencyCompetencyPage,
|
||||
},
|
||||
];
|
||||
|
||||
const tabletRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: AddonCompetencyCompetenciesPage,
|
||||
children: [
|
||||
{
|
||||
path: ':competencyId',
|
||||
component: AddonCompetencyCompetencyPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const routes: Routes = [
|
||||
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
|
||||
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
||||
{
|
||||
path: `:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
component: AddonCompetencyCompetencySummaryPage,
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild(routes),
|
||||
AddonCompetencyCourseCompetenciesPageModule,
|
||||
AddonCompetencyCompetenciesPageModule,
|
||||
AddonCompetencyCompetencyPageModule,
|
||||
AddonCompetencyCompetencySummaryPageModule,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyCourseDetailsLazyModule {}
|
|
@ -20,11 +20,13 @@ import { CoreScreen } from '@services/screen';
|
|||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { AddonCompetencyPlanPage } from './pages/plan/plan';
|
||||
import { AddonCompetencyPlanListPage } from './pages/planlist/planlist';
|
||||
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies';
|
||||
import { AddonCompetencyCompetencyPage } from './pages/competency/competency';
|
||||
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary';
|
||||
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
|
||||
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
|
||||
import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page';
|
||||
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from './competency.module';
|
||||
import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module';
|
||||
import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
|
||||
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies.page';
|
||||
import { AddonCompetencyCompetenciesPageModule } from './pages/competencies/competencies.module';
|
||||
|
||||
const mobileRoutes: Routes = [
|
||||
{
|
||||
|
@ -33,34 +35,28 @@ const mobileRoutes: Routes = [
|
|||
component: AddonCompetencyPlanListPage,
|
||||
},
|
||||
{
|
||||
path: 'competencies',
|
||||
component: AddonCompetencyCompetenciesPage,
|
||||
},
|
||||
{
|
||||
path: 'competencies/:competencyId',
|
||||
component: AddonCompetencyCompetencyPage,
|
||||
},
|
||||
{
|
||||
path: 'course/:courseId',
|
||||
component: AddonCompetencyCourseCompetenciesPage,
|
||||
},
|
||||
{
|
||||
path: 'summary/:competencyId',
|
||||
component: AddonCompetencyCompetencySummaryPage,
|
||||
},
|
||||
{
|
||||
path: ':planId',
|
||||
path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
component: AddonCompetencyPlanPage,
|
||||
},
|
||||
{
|
||||
path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId`,
|
||||
component: AddonCompetencyCompetencyPage,
|
||||
},
|
||||
];
|
||||
|
||||
const tabletRoutes: Routes = [
|
||||
{
|
||||
path: 'summary/:competencyId',
|
||||
component: AddonCompetencyCompetencySummaryPage,
|
||||
path: '',
|
||||
component: AddonCompetencyPlanListPage,
|
||||
children: [
|
||||
{
|
||||
path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
component: AddonCompetencyPlanPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'competencies',
|
||||
path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
component: AddonCompetencyCompetenciesPage,
|
||||
children: [
|
||||
{
|
||||
|
@ -69,40 +65,28 @@ const tabletRoutes: Routes = [
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'course/:courseId',
|
||||
component: AddonCompetencyCourseCompetenciesPage,
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: AddonCompetencyPlanListPage,
|
||||
children: [
|
||||
{
|
||||
path: ':planId',
|
||||
component: AddonCompetencyPlanPage,
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const routes: Routes = [
|
||||
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
|
||||
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
||||
{
|
||||
path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
component: AddonCompetencyCompetencySummaryPage,
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild(routes),
|
||||
CoreSharedModule,
|
||||
AddonCompetencyCourseCompetenciesPageModule,
|
||||
AddonCompetencyCompetenciesPageModule,
|
||||
AddonCompetencyCompetencyPageModule,
|
||||
AddonCompetencyCompetencySummaryPageModule,
|
||||
],
|
||||
declarations: [
|
||||
AddonCompetencyPlanPage,
|
||||
AddonCompetencyPlanListPage,
|
||||
AddonCompetencyCompetenciesPage,
|
||||
AddonCompetencyCompetencyPage,
|
||||
AddonCompetencyCompetencySummaryPage,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyLazyModule {}
|
||||
export class AddonCompetencyLearningPlansLazyModule {}
|
|
@ -30,6 +30,8 @@ import { Routes } from '@angular/router';
|
|||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { CoreCourseIndexRoutingModule } from '@features/course/pages/index/index-routing.module';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
|
||||
|
||||
// List of providers (without handlers).
|
||||
export const ADDON_COMPETENCY_SERVICES: Type<unknown>[] = [
|
||||
|
@ -37,19 +39,29 @@ export const ADDON_COMPETENCY_SERVICES: Type<unknown>[] = [
|
|||
AddonCompetencyHelperProvider,
|
||||
];
|
||||
|
||||
export const ADDON_COMPETENCY_MAIN_PAGE_NAME = 'competency';
|
||||
export const ADDON_COMPETENCY_LEARNING_PLANS_PAGE = 'learning-plans';
|
||||
export const ADDON_COMPETENCY_COMPETENCIES_PAGE = 'competencies';
|
||||
export const ADDON_COMPETENCY_SUMMARY_PAGE = 'summary';
|
||||
|
||||
const mainMenuChildrenRoutes: Routes = [
|
||||
{
|
||||
path: ADDON_COMPETENCY_MAIN_PAGE_NAME,
|
||||
loadChildren: () => import('./competency-lazy.module').then(m => m.AddonCompetencyLazyModule),
|
||||
path: ADDON_COMPETENCY_LEARNING_PLANS_PAGE,
|
||||
loadChildren: () => import('./competency-learning-plans-lazy.module').then(m => m.AddonCompetencyLearningPlansLazyModule),
|
||||
},
|
||||
{
|
||||
path: `${COURSE_PAGE_NAME}/:courseId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
loadChildren: () => import('./competency-course-details-lazy.module').then(m => m.AddonCompetencyCourseDetailsLazyModule),
|
||||
},
|
||||
{
|
||||
path: `${COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
loadChildren: () => import('./competency-course-details-lazy.module').then(m => m.AddonCompetencyCourseDetailsLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
const courseIndexRoutes: Routes = [
|
||||
{
|
||||
path: ADDON_COMPETENCY_MAIN_PAGE_NAME,
|
||||
loadChildren: () => import('@addons/competency/competency-course-lazy.module').then(m => m.AddonCompetencyCourseLazyModule),
|
||||
path: ADDON_COMPETENCY_COMPETENCIES_PAGE,
|
||||
loadChildren: () => import('./competency-course-contents-lazy.module').then(m => m.AddonCompetencyCourseContentsLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// (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 { CoreSharedModule } from '@/core/shared.module';
|
||||
import { AddonCompetencyCompetenciesPage } from './competencies.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreSharedModule,
|
||||
],
|
||||
declarations: [
|
||||
AddonCompetencyCompetenciesPage,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyCompetenciesPageModule {}
|
|
@ -19,7 +19,7 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
|||
import {
|
||||
AddonCompetencyDataForPlanPageCompetency, AddonCompetencyDataForCourseCompetenciesPageCompetency, AddonCompetency,
|
||||
} from '../../services/competency';
|
||||
import { Params, ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
@ -51,8 +51,7 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy
|
|||
this.userId = CoreNavigator.getRouteNumberParam('userId', { route });
|
||||
}
|
||||
|
||||
this.competencies =
|
||||
new AddonCompetencyListManager(AddonCompetencyCompetenciesPage, this.planId, this.courseId, this.userId);
|
||||
this.competencies = new AddonCompetencyListManager(AddonCompetencyCompetenciesPage, this.userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,14 +132,11 @@ type AddonCompetencyDataForPlanPageCompetencyFormatted =
|
|||
*/
|
||||
class AddonCompetencyListManager extends CorePageItemsListManager<AddonCompetencyDataForPlanPageCompetencyFormatted> {
|
||||
|
||||
planId?: number;
|
||||
courseId?: number;
|
||||
userId?: number;
|
||||
private userId?: number;
|
||||
|
||||
constructor(pageComponent: unknown, planId?: number, courseId?: number, userId?: number) {
|
||||
constructor(pageComponent: unknown, userId?: number) {
|
||||
super(pageComponent);
|
||||
this.planId = planId;
|
||||
this.courseId = courseId;
|
||||
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
|
@ -155,11 +151,11 @@ class AddonCompetencyListManager extends CorePageItemsListManager<AddonCompetenc
|
|||
* @inheritdoc
|
||||
*/
|
||||
protected getItemQueryParams(): Params {
|
||||
if (this.planId) {
|
||||
return { planId: this.planId };
|
||||
} else {
|
||||
return { courseId: this.courseId, userId: this.userId };
|
||||
if (this.userId) {
|
||||
return { userId: this.userId };
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// (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 { CoreSharedModule } from '@/core/shared.module';
|
||||
import { AddonCompetencyCompetencyPage } from './competency.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreSharedModule,
|
||||
],
|
||||
declarations: [
|
||||
AddonCompetencyCompetencyPage,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyCompetencyPageModule {}
|
|
@ -32,7 +32,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { IonRefresher } from '@ionic/angular';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Page that displays the competency information.
|
||||
|
@ -183,8 +183,8 @@ export class AddonCompetencyCompetencyPage implements OnInit {
|
|||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId,
|
||||
CoreNavigator.navigate(
|
||||
`../${competencyId}/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
{
|
||||
params: { contextLevel: this.contextLevel, contextInstanceId: this.contextInstanceId },
|
||||
},
|
|
@ -0,0 +1,28 @@
|
|||
// (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 { CoreSharedModule } from '@/core/shared.module';
|
||||
import { AddonCompetencyCompetencySummaryPage } from './competencysummary.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreSharedModule,
|
||||
],
|
||||
declarations: [
|
||||
AddonCompetencyCompetencySummaryPage,
|
||||
],
|
||||
})
|
||||
export class AddonCompetencyCompetencySummaryPageModule {}
|
|
@ -19,7 +19,7 @@ import { IonRefresher } from '@ionic/angular';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Page that displays the competency summary.
|
||||
|
@ -101,8 +101,8 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit {
|
|||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId,
|
||||
CoreNavigator.navigate(
|
||||
`../../${competencyId}/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
{
|
||||
params: { contextLevel: this.contextLevel, contextInstanceId: this.contextInstanceId },
|
||||
},
|
|
@ -20,7 +20,7 @@ import { IonRefresher } from '@ionic/angular';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Page that displays the list of competencies of a course.
|
||||
|
@ -80,12 +80,7 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit {
|
|||
* @param competencyId
|
||||
*/
|
||||
openCompetency(competencyId: number): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
|
||||
{
|
||||
params: { courseId: this.courseId, userId: this.userId },
|
||||
},
|
||||
);
|
||||
CoreNavigator.navigate('./' + competencyId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,11 +89,15 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit {
|
|||
* @param competencyId
|
||||
*/
|
||||
openCompetencySummary(competencyId: number): void {
|
||||
CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId, {
|
||||
params: {
|
||||
contextLevel: ContextLevel.COURSE,
|
||||
contextInstanceId: this.courseId,
|
||||
} });
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`./${competencyId}/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
{
|
||||
params: {
|
||||
contextLevel: ContextLevel.COURSE,
|
||||
contextInstanceId: this.courseId,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,6 @@ import { AddonCompetencyHelper } from '../../services/competency-helper';
|
|||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreUserProfile } from '@features/user/services/user';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Page that displays a learning plan.
|
||||
|
@ -79,10 +78,9 @@ export class AddonCompetencyPlanPage implements OnInit {
|
|||
* @param competencyId
|
||||
*/
|
||||
openCompetency(competencyId: number): void {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
|
||||
{ params: { planId: this.planId } },
|
||||
);
|
||||
CoreNavigator.navigate('./' + competencyId, {
|
||||
params: { userId: this.user?.id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
|
@ -20,6 +20,8 @@ import { AddonCompetencyProvider, AddonCompetencyPlan, AddonCompetency } from '.
|
|||
import { AddonCompetencyHelper } from '../../services/competency-helper';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module';
|
||||
import { Params } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Page that displays the list of learning plans.
|
||||
|
@ -28,7 +30,7 @@ import { CorePageItemsListManager } from '@classes/page-items-list-manager';
|
|||
selector: 'page-addon-competency-planlist',
|
||||
templateUrl: 'planlist.html',
|
||||
})
|
||||
export class AddonCompetencyPlanListPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
export class AddonCompetencyPlanListPage implements AfterViewInit, OnDestroy {
|
||||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
|
@ -36,14 +38,9 @@ export class AddonCompetencyPlanListPage implements OnInit, AfterViewInit, OnDes
|
|||
plans: AddonCompetencyPlanListManager;
|
||||
|
||||
constructor() {
|
||||
this.plans = new AddonCompetencyPlanListManager(AddonCompetencyPlanListPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
|
||||
this.plans = new AddonCompetencyPlanListManager(AddonCompetencyPlanListPage, this.userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,15 +115,30 @@ type AddonCompetencyPlanFormatted = AddonCompetencyPlan & {
|
|||
*/
|
||||
class AddonCompetencyPlanListManager extends CorePageItemsListManager<AddonCompetencyPlanFormatted> {
|
||||
|
||||
constructor(pageComponent: unknown) {
|
||||
private userId?: number;
|
||||
|
||||
constructor(pageComponent: unknown, userId?: number) {
|
||||
super(pageComponent);
|
||||
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected getItemPath(plan: AddonCompetencyPlanFormatted): string {
|
||||
return String(plan.id);
|
||||
return `${plan.id}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected getItemQueryParams(): Params {
|
||||
if (this.userId) {
|
||||
return { userId: this.userId };
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonCompetency } from '../competency';
|
||||
|
@ -37,17 +38,29 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink
|
|||
|
||||
return [{
|
||||
action: (siteId: string): void => {
|
||||
const pageParams = {
|
||||
planId: params.planid,
|
||||
courseId: courseId,
|
||||
userId: params.userid,
|
||||
};
|
||||
if (courseId) {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`,
|
||||
{
|
||||
params: { userId: params.userid },
|
||||
siteId,
|
||||
},
|
||||
);
|
||||
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + params.competencyid,
|
||||
{ params: pageParams, siteId },
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.planid) {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
`${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/competencies/${params.planid}`,
|
||||
{
|
||||
params: { userId: params.userid },
|
||||
siteId,
|
||||
},
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/service
|
|||
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
|
||||
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
|
||||
import { ContextLevel } from '@/core/constants';
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module';
|
||||
|
||||
/**
|
||||
* Course nav handler.
|
||||
|
@ -75,7 +75,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
|
|||
return {
|
||||
title: 'addon.competency.competencies',
|
||||
class: 'addon-competency-course-handler',
|
||||
page: ADDON_COMPETENCY_MAIN_PAGE_NAME,
|
||||
page: ADDON_COMPETENCY_COMPETENCIES_PAGE,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
|
@ -36,7 +36,7 @@ export class AddonCompetencyPlanLinkHandlerService extends CoreContentLinksHandl
|
|||
return [{
|
||||
action: (siteId: string): void => {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/' + params.id,
|
||||
`${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/${params.id}`,
|
||||
{ siteId },
|
||||
);
|
||||
},
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
|
@ -36,7 +36,7 @@ export class AddonCompetencyPlansLinkHandlerService extends CoreContentLinksHand
|
|||
return [{
|
||||
action: (siteId: string): void => {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME,
|
||||
ADDON_COMPETENCY_LEARNING_PLANS_PAGE,
|
||||
{ params: { userId: params.userid }, siteId },
|
||||
);
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
|
||||
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
@ -56,7 +57,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
|
|||
|
||||
await CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlan(planId, notification.site));
|
||||
|
||||
await CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME + '/' + planId, {
|
||||
await CoreNavigator.navigateToSitePath(`${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/${planId}`, {
|
||||
siteId: notification.site,
|
||||
});
|
||||
|
||||
|
@ -71,15 +72,30 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
|
|||
const userId = Number(contextUrlParams.userid);
|
||||
|
||||
await CoreUtils.ignoreErrors(AddonCompetency.invalidateCompetencyInPlan(planId, competencyId, notification.site));
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
|
||||
{
|
||||
params: { planId, courseId, userId },
|
||||
siteId: notification.site,
|
||||
},
|
||||
);
|
||||
|
||||
return;
|
||||
if (courseId) {
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${competencyId}`,
|
||||
{
|
||||
params: { userId },
|
||||
siteId: notification.site,
|
||||
},
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (planId) {
|
||||
await CoreNavigator.navigateToSitePath(
|
||||
`${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/competencies/${planId}/${competencyId}`,
|
||||
{
|
||||
params: { userId },
|
||||
siteId: notification.site,
|
||||
},
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Open the list of plans.
|
||||
|
@ -87,7 +103,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
|
|||
|
||||
await CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlans(userId, notification.site));
|
||||
|
||||
await CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME, {
|
||||
await CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_LEARNING_PLANS_PAGE, {
|
||||
params: { userId },
|
||||
siteId: notification.site,
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
|
@ -33,14 +33,12 @@ export class AddonCompetencyUserCompetencyLinkHandlerService extends CoreContent
|
|||
* @inheritdoc
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] {
|
||||
|
||||
return [{
|
||||
action: (siteId: string): void => {
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + params.id,
|
||||
`${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${params.id}/${ADDON_COMPETENCY_SUMMARY_PAGE}`,
|
||||
{ siteId },
|
||||
);
|
||||
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
|
||||
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { CoreUserProfile } from '@features/user/services/user';
|
||||
import { CoreUserProfileHandler, CoreUserDelegateService, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
|
||||
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonCompetency } from '../competency';
|
||||
|
@ -69,12 +71,8 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
CoreNavigator.navigateToSitePath(
|
||||
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/course/' + courseId,
|
||||
{
|
||||
params: { userId: user.id },
|
||||
},
|
||||
[COURSE_PAGE_NAME, courseId, PARTICIPANTS_PAGE_NAME, user.id, ADDON_COMPETENCY_COMPETENCIES_PAGE].join('/'),
|
||||
);
|
||||
|
||||
},
|
||||
};
|
||||
} else {
|
||||
|
@ -85,7 +83,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
|
|||
action: (event, user): void => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME, {
|
||||
CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_LEARNING_PLANS_PAGE, {
|
||||
params: { userId: user.id },
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue