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-tab-bar slot="top" class="core-tabs-bar" [hidden]="!tabs || numTabsShown < 1">
|
||||||
<ion-spinner *ngIf="!hideUntil"></ion-spinner>
|
<ion-spinner *ngIf="!hideUntil"></ion-spinner>
|
||||||
<ion-row *ngIf="hideUntil">
|
<ion-row *ngIf="hideUntil">
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { RouterModule, Routes } from '@angular/router';
|
||||||
import { CoreHomeRoutingModule } from '../mainmenu/pages/home/home-routing.module';
|
import { CoreHomeRoutingModule } from '../mainmenu/pages/home/home-routing.module';
|
||||||
import { CoreHomeDelegate } from '../mainmenu/services/home.delegate';
|
import { CoreHomeDelegate } from '../mainmenu/services/home.delegate';
|
||||||
import { CoreDashboardHomeHandler } from './services/handlers/dashboard.home';
|
import { CoreDashboardHomeHandler } from './services/handlers/dashboard.home';
|
||||||
|
import { CoreCoursesMyCoursesHomeHandler } from './services/handlers/my-courses.home';
|
||||||
|
|
||||||
const homeRoutes: Routes = [
|
const homeRoutes: Routes = [
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,12 @@ const homeRoutes: Routes = [
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('@features/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
|
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 = [
|
const routes: Routes = [
|
||||||
|
@ -43,7 +50,8 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'categories/:id',
|
path: 'categories/:id',
|
||||||
loadChildren: () =>
|
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',
|
path: 'all',
|
||||||
|
@ -84,6 +92,7 @@ const routes: Routes = [
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CoreDashboardHomeHandler,
|
CoreDashboardHomeHandler,
|
||||||
|
CoreCoursesMyCoursesHomeHandler,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CoreCoursesModule {
|
export class CoreCoursesModule {
|
||||||
|
@ -91,8 +100,10 @@ export class CoreCoursesModule {
|
||||||
constructor(
|
constructor(
|
||||||
homeDelegate: CoreHomeDelegate,
|
homeDelegate: CoreHomeDelegate,
|
||||||
coursesDashboardHandler: CoreDashboardHomeHandler,
|
coursesDashboardHandler: CoreDashboardHomeHandler,
|
||||||
|
coursesMyCoursesHandler: CoreCoursesMyCoursesHomeHandler,
|
||||||
) {
|
) {
|
||||||
homeDelegate.registerHandler(coursesDashboardHandler);
|
homeDelegate.registerHandler(coursesDashboardHandler);
|
||||||
|
homeDelegate.registerHandler(coursesMyCoursesHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,21 @@
|
||||||
<ion-title>{{ 'core.courses.mycourses' | translate }}</ion-title>
|
<ion-title>{{ 'core.courses.mycourses' | translate }}</ion-title>
|
||||||
|
|
||||||
<ion-buttons slot="end">
|
<ion-buttons slot="end">
|
||||||
<ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate">
|
<core-navbar-buttons>
|
||||||
<ion-icon name="fas-search" slot="icon-only"></ion-icon>
|
<ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate">
|
||||||
</ion-button>
|
<ion-icon name="fas-search" slot="icon-only"></ion-icon>
|
||||||
<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-button>
|
||||||
<ion-spinner *ngIf="downloadAllCoursesBadge == '' && downloadAllCoursesLoading"
|
<ng-container *ngIf="downloadAllCoursesEnabled && courses && courses.length >= 2">
|
||||||
[attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
<ion-button *ngIf="!downloadAllCoursesLoading" (click)="prefetchCourses()"
|
||||||
<ion-badge *ngIf="downloadAllCoursesBadge != '' && downloadAllCoursesLoading"
|
[attr.aria-label]="'core.courses.downloadcourses' | translate">
|
||||||
[attr.aria-label]="'core.downloading' | translate">{{downloadAllCoursesBadge}}</ion-badge>
|
<ion-icon [name]="downloadAllCoursesIcon" slot="icon-only"></ion-icon>
|
||||||
</ng-container>
|
</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-buttons>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home.delegate';
|
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home.delegate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to add Home into main menu.
|
* Handler to add dashboard into home page.
|
||||||
*/
|
*/
|
||||||
Injectable();
|
Injectable();
|
||||||
export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
||||||
|
@ -41,7 +41,7 @@ export class CoreDashboardHomeHandler implements CoreHomeHandler {
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
async isEnabledForSite(siteId?: string): Promise<boolean> {
|
||||||
// @todo
|
// @todo return this.blockDelegate.hasSupportedBlock(this.blocks);
|
||||||
return true;
|
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';
|
import { CoreSiteHome } from '../sitehome';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to add Home into main menu.
|
* Handler to add site home into home page.
|
||||||
*/
|
*/
|
||||||
Injectable();
|
Injectable();
|
||||||
export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
|
export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
|
||||||
|
|
Loading…
Reference in New Issue