MOBILE-3594 sitehome: Add my courses tab as a fallback
parent
1ffcf4c877
commit
2ce1950210
|
@ -1,4 +1,4 @@
|
|||
<ion-tabs>
|
||||
<ion-tabs class="hide-header">
|
||||
<ion-tab-bar slot="top" class="core-tabs-bar" [hidden]="!tabs || numTabsShown < 1">
|
||||
<ion-spinner *ngIf="!hideUntil"></ion-spinner>
|
||||
<ion-row *ngIf="hideUntil">
|
||||
|
|
|
@ -17,6 +17,7 @@ import { RouterModule, Routes } from '@angular/router';
|
|||
import { CoreHomeRoutingModule } from '../mainmenu/pages/home/home-routing.module';
|
||||
import { CoreHomeDelegate } from '../mainmenu/services/home.delegate';
|
||||
import { CoreDashboardHomeHandler } from './services/handlers/dashboard.home';
|
||||
import { CoreCoursesMyCoursesHomeHandler } from './services/handlers/my-courses.home';
|
||||
|
||||
const homeRoutes: Routes = [
|
||||
{
|
||||
|
@ -24,6 +25,12 @@ const homeRoutes: Routes = [
|
|||
loadChildren: () =>
|
||||
import('@features/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
|
||||
},
|
||||
{
|
||||
path: 'courses/my',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/my-courses/my-courses.page.module')
|
||||
.then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
const routes: Routes = [
|
||||
|
@ -43,7 +50,8 @@ const routes: Routes = [
|
|||
{
|
||||
path: 'categories/:id',
|
||||
loadChildren: () =>
|
||||
import('@features/courses/pages/categories/categories.page.module').then(m => m.CoreCoursesCategoriesPageModule),
|
||||
import('@features/courses/pages/categories/categories.page.module')
|
||||
.then(m => m.CoreCoursesCategoriesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'all',
|
||||
|
@ -84,6 +92,7 @@ const routes: Routes = [
|
|||
],
|
||||
providers: [
|
||||
CoreDashboardHomeHandler,
|
||||
CoreCoursesMyCoursesHomeHandler,
|
||||
],
|
||||
})
|
||||
export class CoreCoursesModule {
|
||||
|
@ -91,8 +100,10 @@ export class CoreCoursesModule {
|
|||
constructor(
|
||||
homeDelegate: CoreHomeDelegate,
|
||||
coursesDashboardHandler: CoreDashboardHomeHandler,
|
||||
coursesMyCoursesHandler: CoreCoursesMyCoursesHomeHandler,
|
||||
) {
|
||||
homeDelegate.registerHandler(coursesDashboardHandler);
|
||||
homeDelegate.registerHandler(coursesMyCoursesHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,19 +6,21 @@
|
|||
<ion-title>{{ 'core.courses.mycourses' | translate }}</ion-title>
|
||||
|
||||
<ion-buttons slot="end">
|
||||
<ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate">
|
||||
<ion-icon name="fas-search" slot="icon-only"></ion-icon>
|
||||
</ion-button>
|
||||
<ng-container *ngIf="downloadAllCoursesEnabled && courses && courses.length >= 2">
|
||||
<ion-button *ngIf="!downloadAllCoursesLoading" (click)="prefetchCourses()"
|
||||
[attr.aria-label]="'core.courses.downloadcourses' | translate">
|
||||
<ion-icon [name]="downloadAllCoursesIcon" slot="icon-only"></ion-icon>
|
||||
<core-navbar-buttons>
|
||||
<ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate">
|
||||
<ion-icon name="fas-search" slot="icon-only"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-spinner *ngIf="downloadAllCoursesBadge == '' && downloadAllCoursesLoading"
|
||||
[attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
||||
<ion-badge *ngIf="downloadAllCoursesBadge != '' && downloadAllCoursesLoading"
|
||||
[attr.aria-label]="'core.downloading' | translate">{{downloadAllCoursesBadge}}</ion-badge>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="downloadAllCoursesEnabled && courses && courses.length >= 2">
|
||||
<ion-button *ngIf="!downloadAllCoursesLoading" (click)="prefetchCourses()"
|
||||
[attr.aria-label]="'core.courses.downloadcourses' | translate">
|
||||
<ion-icon [name]="downloadAllCoursesIcon" slot="icon-only"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-spinner *ngIf="downloadAllCoursesBadge == '' && downloadAllCoursesLoading"
|
||||
[attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
||||
<ion-badge *ngIf="downloadAllCoursesBadge != '' && downloadAllCoursesLoading"
|
||||
[attr.aria-label]="'core.downloading' | translate">{{downloadAllCoursesBadge}}</ion-badge>
|
||||
</ng-container>
|
||||
</core-navbar-buttons>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home.delegate';
|
||||
|
||||
/**
|
||||
* Handler to add Home into main menu.
|
||||
* Handler to add dashboard into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
||||
|
@ -41,7 +41,7 @@ export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
|||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
||||
// @todo
|
||||
// @todo return this.blockDelegate.hasSupportedBlock(this.blocks);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
// (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 { Injectable } from '@angular/core';
|
||||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home.delegate';
|
||||
|
||||
/**
|
||||
* Handler to add my courses into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreCoursesMyCoursesHomeHandler implements CoreHomeHandler {
|
||||
|
||||
name = 'CoreCoursesMyCourses';
|
||||
priority = 900;
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled on a site level.
|
||||
*
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
isEnabled(): Promise<boolean> {
|
||||
return this.isEnabledForSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled on a certain site.
|
||||
*
|
||||
* @param siteId Site ID. If not defined, current site.
|
||||
* @return Whether or not the handler is enabled on a site level.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
||||
// @todo return !this.blockDelegate.hasSupportedBlock(this.blocks) && !CoreSiteHome.instance.isAvailable(siteId);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data needed to render the handler.
|
||||
*
|
||||
* @return Data needed to render the handler.
|
||||
*/
|
||||
getDisplayData(): CoreHomeHandlerToDisplay {
|
||||
return {
|
||||
title: 'core.courses.mycourses',
|
||||
page: 'courses/my',
|
||||
class: 'core-courses-my-courses-handler',
|
||||
icon: 'fas-graduation-cap',
|
||||
selectPriority: 900,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@ import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/se
|
|||
import { CoreSiteHome } from '../sitehome';
|
||||
|
||||
/**
|
||||
* Handler to add Home into main menu.
|
||||
* Handler to add site home into home page.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
|
||||
|
|
Loading…
Reference in New Issue