MOBILE-3934 grades: Refactor routes
parent
7265611dda
commit
803ad32ec8
|
@ -23,14 +23,10 @@ import { CoreGradesCoursePage } from './pages/course/course.page';
|
|||
import { CoreGradesCoursePageModule } from './pages/course/course.module';
|
||||
import { CoreGradesCoursesPage } from './pages/courses/courses.page';
|
||||
import { CoreGradesGradePage } from './pages/grade/grade.page';
|
||||
import { CoreGradesUserHandlerService } from './services/handlers/user';
|
||||
|
||||
const mobileRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
data: {
|
||||
mainMenuTabRoot: CoreGradesUserHandlerService.PAGE_NAME,
|
||||
},
|
||||
component: CoreGradesCoursesPage,
|
||||
},
|
||||
{
|
||||
|
@ -46,9 +42,6 @@ const mobileRoutes: Routes = [
|
|||
const tabletRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
data: {
|
||||
mainMenuTabRoot: CoreGradesUserHandlerService.PAGE_NAME,
|
||||
},
|
||||
component: CoreGradesCoursesPage,
|
||||
children: [
|
||||
{
|
||||
|
@ -85,4 +78,4 @@ const routes: Routes = [
|
|||
CoreGradesGradePage,
|
||||
],
|
||||
})
|
||||
export class CoreGradesLazyModule {}
|
||||
export class CoreGradesCoursesLazyModule {}
|
|
@ -15,16 +15,17 @@
|
|||
import { APP_INITIALIZER, NgModule, Type } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { CoreCourseIndexRoutingModule } from '@features/course/pages/index/index-routing.module';
|
||||
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
|
||||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { CoreUserDelegate } from '@features/user/services/user-delegate';
|
||||
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
|
||||
import { CoreGradesProvider } from './services/grades';
|
||||
import { CoreGradesHelperProvider } from './services/grades-helper';
|
||||
import { CoreGradesCourseOptionHandler } from './services/handlers/course-option';
|
||||
import { CoreGradesOverviewLinkHandler } from './services/handlers/overview-link';
|
||||
import { CoreGradesUserHandler, CoreGradesUserHandlerService } from './services/handlers/user';
|
||||
import { CoreGradesUserHandler } from './services/handlers/user';
|
||||
import { CoreGradesUserLinkHandler } from './services/handlers/user-link';
|
||||
|
||||
export const CORE_GRADES_SERVICES: Type<unknown>[] = [
|
||||
|
@ -32,28 +33,29 @@ export const CORE_GRADES_SERVICES: Type<unknown>[] = [
|
|||
CoreGradesHelperProvider,
|
||||
];
|
||||
|
||||
const routes: Routes = [
|
||||
export const GRADES_PAGE_NAME = 'grades';
|
||||
|
||||
const mainMenuChildrenRoutes: Routes = [
|
||||
{
|
||||
path: CoreGradesUserHandlerService.PAGE_NAME,
|
||||
loadChildren: () => import('@features/grades/grades-lazy.module').then(m => m.CoreGradesLazyModule),
|
||||
path: GRADES_PAGE_NAME,
|
||||
loadChildren: () => import('./grades-courses-lazy.module').then(m => m.CoreGradesCoursesLazyModule),
|
||||
},
|
||||
{
|
||||
path: 'user-grades/:courseId',
|
||||
loadChildren: () => import('@features/grades/grades-course-lazy.module').then(m => m.CoreGradesCourseLazyModule),
|
||||
path: `${COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${GRADES_PAGE_NAME}`,
|
||||
loadChildren: () => import('./grades-course-lazy.module').then(m => m.CoreGradesCourseLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
const courseIndexRoutes: Routes = [
|
||||
{
|
||||
path: 'grades',
|
||||
loadChildren: () => import('@features/grades/grades-course-lazy.module').then(m => m.CoreGradesCourseLazyModule),
|
||||
path: GRADES_PAGE_NAME,
|
||||
loadChildren: () => import('./grades-course-lazy.module').then(m => m.CoreGradesCourseLazyModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreMainMenuTabRoutingModule.forChild(routes),
|
||||
CoreMainMenuRoutingModule.forChild({ children: routes }),
|
||||
CoreMainMenuTabRoutingModule.forChild(mainMenuChildrenRoutes),
|
||||
CoreCourseIndexRoutingModule.forChild({ children: courseIndexRoutes }),
|
||||
],
|
||||
providers: [
|
||||
|
|
|
@ -159,7 +159,11 @@ class CoreGradesCourseManager extends CorePageItemsListManager<CoreGradesFormatt
|
|||
*/
|
||||
async select(row: CoreGradesFormattedTableRowFilled): Promise<void> {
|
||||
if (this.outsideGradesTab) {
|
||||
await CoreNavigator.navigateToSitePath(`/grades/${this.courseId}/${row.id}`);
|
||||
await CoreNavigator.navigateToSitePath(`/grades/${this.courseId}/${row.id}`, {
|
||||
params: {
|
||||
userId: this.userId,
|
||||
},
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import { CoreNavigator } from '@services/navigator';
|
|||
import { makeSingleton, Translate } from '@singletons';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { GRADES_PAGE_NAME } from '../grades.module';
|
||||
|
||||
/**
|
||||
* Service that provides some features regarding grades information.
|
||||
|
@ -472,10 +473,7 @@ export class CoreGradesHelperProvider {
|
|||
const gradeId = item.id;
|
||||
|
||||
await CoreUtils.ignoreErrors(
|
||||
CoreNavigator.navigateToSitePath(`/grades/${courseId}/${gradeId}`, {
|
||||
siteId,
|
||||
params: { userId },
|
||||
}),
|
||||
CoreNavigator.navigateToSitePath(`/${GRADES_PAGE_NAME}/${courseId}/${gradeId}`, { siteId }),
|
||||
);
|
||||
} catch (error) {
|
||||
try {
|
||||
|
@ -483,10 +481,7 @@ export class CoreGradesHelperProvider {
|
|||
if (userId && userId != currentUserId) {
|
||||
// View another user grades. Open the grades page directly.
|
||||
await CoreUtils.ignoreErrors(
|
||||
CoreNavigator.navigateToSitePath(`/grades/${courseId}`, {
|
||||
siteId,
|
||||
params: { userId },
|
||||
}),
|
||||
CoreNavigator.navigateToSitePath(`/${GRADES_PAGE_NAME}/${courseId}`, { siteId }),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -502,7 +497,7 @@ export class CoreGradesHelperProvider {
|
|||
await CoreCourseHelper.getAndOpenCourse(courseId, { selectedTab: 'CoreGrades' }, siteId);
|
||||
} catch (error) {
|
||||
// Cannot get course for some reason, just open the grades page.
|
||||
await CoreNavigator.navigateToSitePath(`/grades/${courseId}`, { siteId });
|
||||
await CoreNavigator.navigateToSitePath(`/${GRADES_PAGE_NAME}/${courseId}`, { siteId });
|
||||
}
|
||||
} finally {
|
||||
modal.dismiss();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { GRADES_PAGE_NAME } from '@features/grades/grades.module';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreGrades } from '../grades';
|
||||
|
@ -36,10 +37,7 @@ export class CoreGradesOverviewLinkHandlerService extends CoreContentLinksHandle
|
|||
getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||
return [{
|
||||
action: siteId => {
|
||||
CoreNavigator.navigateToSitePath('/grades', {
|
||||
siteId,
|
||||
preferCurrentTab: false,
|
||||
});
|
||||
CoreNavigator.navigateToSitePath(GRADES_PAGE_NAME, { siteId });
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||
import { GRADES_PAGE_NAME } from '@features/grades/grades.module';
|
||||
|
||||
import { CoreGrades } from '@features/grades/services/grades';
|
||||
import { CoreUserProfile } from '@features/user/services/user';
|
||||
|
@ -21,6 +23,7 @@ import {
|
|||
CoreUserProfileHandler,
|
||||
CoreUserProfileHandlerData,
|
||||
} from '@features/user/services/user-delegate';
|
||||
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -32,8 +35,6 @@ import { makeSingleton } from '@singletons';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'grades';
|
||||
|
||||
name = 'CoreGrades:viewGrades';
|
||||
priority = 400;
|
||||
type = CoreUserDelegateService.TYPE_NEW_PAGE;
|
||||
|
@ -81,9 +82,9 @@ export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
|
|||
action: (event, user, courseId): void => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
CoreNavigator.navigateToSitePath(`/user-grades/${courseId}`, {
|
||||
params: { userId: user.id },
|
||||
});
|
||||
CoreNavigator.navigateToSitePath(
|
||||
[COURSE_PAGE_NAME, courseId, PARTICIPANTS_PAGE_NAME, user.id, GRADES_PAGE_NAME].join('/'),
|
||||
);
|
||||
},
|
||||
};
|
||||
} else {
|
||||
|
@ -94,7 +95,7 @@ export class CoreGradesUserHandlerService implements CoreUserProfileHandler {
|
|||
action: (event): void => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
CoreNavigator.navigateToSitePath(CoreGradesUserHandlerService.PAGE_NAME);
|
||||
CoreNavigator.navigateToSitePath(GRADES_PAGE_NAME);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue