Merge pull request #2825 from dpalou/MOBILE-3320

Mobile 3320
main
Pau Ferrer Ocaña 2021-06-11 12:29:19 +02:00 committed by GitHub
commit ee3bf7c2e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 151 additions and 143 deletions

View File

@ -40,6 +40,7 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl
*/
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData {
const linkParams: Params = contextLevel == 'course' ? { courseId: instanceId } : {};
linkParams.upcoming = true;
return {
title: 'addon.block_calendarupcoming.pluginname',

View File

@ -21,10 +21,14 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp
import { CoreTagComponentsModule } from '@features/tag/components/components.module';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonBlogMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes {
return [
...buildTabMainRoutes(injector, {
data: {
mainMenuTabRoot: AddonBlogMainMenuHandlerService.PAGE_NAME,
},
component: AddonBlogEntriesPage,
}),
];

View File

@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core';
import { Route, RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu';
export const AddonCalendarEditRoute: Route = {
path: 'edit/:eventId',
@ -33,14 +34,14 @@ function buildRoutes(injector: Injector): Routes {
{
path: 'index',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME,
},
loadChildren: () => import('@/addons/calendar/pages/index/index.module').then(m => m.AddonCalendarIndexPageModule),
},
{
path: 'list',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME,
},
loadChildren: () => import('@/addons/calendar/pages/list/list.module').then(m => m.AddonCalendarListPageModule),
},

View File

@ -25,11 +25,15 @@ 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 { AddonCompetencyMainMenuHandlerService } from './services/handlers/mainmenu';
const mobileRoutes: Routes = [
{
path: '',
pathMatch: 'full',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage,
},
{
@ -75,6 +79,9 @@ const tabletRoutes: Routes = [
},
{
path: '',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage,
children: [
{

View File

@ -22,12 +22,13 @@ import { CoreSharedModule } from '@/core/shared.module';
import { CoreSearchComponentsModule } from '@features/search/components/components.module';
import { AddonMessagesDiscussions35Page } from './discussions.page';
import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu';
const mobileRoutes: Routes = [
{
path: '',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
},
component: AddonMessagesDiscussions35Page,
},
@ -38,7 +39,7 @@ const tabletRoutes: Routes = [
{
path: '',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
},
component: AddonMessagesDiscussions35Page,
children: [

View File

@ -21,12 +21,13 @@ import { CoreScreen } from '@services/screen';
import { CoreSharedModule } from '@/core/shared.module';
import { AddonMessagesGroupConversationsPage } from './group-conversations.page';
import { AddonMessagesMainMenuHandlerService } from '@addons/messages/services/handlers/mainmenu';
const mobileRoutes: Routes = [
{
path: '',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
},
component: AddonMessagesGroupConversationsPage,
},
@ -37,7 +38,7 @@ const tabletRoutes: Routes = [
{
path: '',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonMessagesMainMenuHandlerService.PAGE_NAME,
},
component: AddonMessagesGroupConversationsPage,
children: [

View File

@ -211,13 +211,9 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
}
/**
* Prefetch a module.
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @return Promise resolved when done.
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchAssign.bind(this, module, courseId));
}
@ -226,12 +222,11 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
protected async prefetchAssign(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const userId = CoreSites.getCurrentSiteUserId();
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
const siteId = CoreSites.getCurrentSiteId();
const options: CoreSitesCommonWSOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreUser } from '@features/user/services/user';
import { CoreGroups } from '@services/groups';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { AddonModChat, AddonModChatProvider, AddonModChatSession } from '../chat';
@ -64,7 +64,7 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChat.bind(this, module, courseId));
}
@ -73,10 +73,10 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet
*
* @param module The module object returned by WS.
* @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
protected async prefetchChat(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const options = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreUser } from '@features/user/services/user';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
@ -38,7 +38,7 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchChoice.bind(this, module, courseId, !!single));
}
@ -55,10 +55,8 @@ export class AddonModChoicePrefetchHandlerService extends CoreCourseActivityPref
module: CoreCourseAnyModuleData,
courseId: number,
single: boolean,
siteId?: string,
siteId: string,
): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,

View File

@ -212,7 +212,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchDatabase.bind(this, module, courseId));
}
@ -221,12 +221,10 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
protected async prefetchDatabase(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const options = {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -17,7 +17,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreFilepool } from '@services/filepool';
import { CoreGroups } from '@services/groups';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws';
@ -122,7 +122,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchFeedback.bind(this, module, courseId));
}
@ -131,10 +131,10 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
protected async prefetchFeedback(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,

View File

@ -171,15 +171,9 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
}
/**
* Prefetch a module.
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchForum.bind(this, module, courseId, single));
}

View File

@ -97,7 +97,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchGlossary.bind(this, module, courseId));
}
@ -110,8 +110,6 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
* @return Promise resolved when done.
*/
protected async prefetchGlossary(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const options = {
cmId: module.id,
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -76,7 +76,7 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchActivity.bind(this, module, courseId));
}
@ -91,10 +91,8 @@ export class AddonModH5PActivityPrefetchHandlerService extends CoreCourseActivit
protected async prefetchActivity(
module: CoreCourseAnyModuleData,
courseId: number,
siteId?: string,
siteId: string,
): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const h5pActivity = await AddonModH5PActivity.getH5PActivity(courseId, module.id, {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,

View File

@ -231,17 +231,10 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
}
/**
* Prefetch a module.
*
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
* @inheritdoc
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, single));
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchLesson.bind(this, module, courseId, !!single));
}
/**
@ -250,12 +243,15 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchLesson(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
courseId = courseId || module.course || CoreSites.getCurrentSiteHomeId();
protected async prefetchLesson(
module: CoreCourseAnyModuleData,
courseId: number,
single: boolean,
siteId: string,
): Promise<void> {
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,
siteId,

View File

@ -269,7 +269,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
*/
async prefetch(
module: SyncedModule,
courseId?: number,
courseId: number,
single?: boolean,
dirPath?: string,
canStart: boolean = true,
@ -282,9 +282,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
return;
}
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, single, siteId, canStart));
return this.prefetchPackage(module, courseId, this.prefetchQuiz.bind(this, module, courseId, !!single, canStart));
}
/**
@ -293,16 +291,16 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @param canStart If true, start a new attempt if needed.
* @param siteId Site ID.
* @return Promise resolved when done.
*/
protected async prefetchQuiz(
module: CoreCourseAnyModuleData,
courseId: number,
single: boolean,
siteId: string,
canStart: boolean,
siteId: string,
): Promise<void> {
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -47,12 +47,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
dirPath?: string,
onProgress?: AddonModScormProgressCallback,
): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage(
module,
courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, true, siteId, false, onProgress),
this.downloadOrPrefetchScorm.bind(this, module, courseId, true, false, onProgress),
);
}
@ -62,18 +60,18 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
* @param module Module.
* @param courseId Course ID the module belongs to.
* @param single True if we're downloading a single module, false if we're downloading a whole section.
* @param siteId Site ID.
* @param prefetch True to prefetch, false to download right away.
* @param onProgress Function to call on progress.
* @param siteId Site ID.
* @return Promise resolved with the "extra" data to store: the hash of the file.
*/
protected async downloadOrPrefetchScorm(
module: CoreCourseAnyModuleData,
courseId: number,
single: boolean,
siteId: string,
prefetch: boolean,
onProgress?: AddonModScormProgressCallback,
onProgress: AddonModScormProgressCallback | undefined,
siteId: string,
): Promise<string> {
const scorm = await this.getScorm(module, courseId, siteId);
@ -370,12 +368,10 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
dirPath?: string,
onProgress?: AddonModScormProgressCallback,
): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
return this.prefetchPackage(
module,
courseId,
this.downloadOrPrefetchScorm.bind(this, module, courseId, single, siteId, true, onProgress),
this.downloadOrPrefetchScorm.bind(this, module, courseId, single, true, onProgress),
);
}

View File

@ -78,38 +78,41 @@
</ng-container>
<!-- Subquestion -->
<ion-radio-group [(ngModel)]="answers[question.name]" [required]="question.required" [name]="question.name">
<ion-row *ngIf="question.parent !== 0" class="ion-align-items-center ion-padding-horizontal" [class.even]="isEven">
<ng-container *ngIf="question.parent !== 0">
<ion-radio-group [(ngModel)]="answers[question.name]" [required]="question.required" [name]="question.name">
<ion-row *ngIf="question.parent !== 0" class="ion-align-items-center ion-padding-horizontal"
[class.even]="isEven">
<ion-col size="7">
<ion-label id="addon-mod_survey-{{question.id}}">
<span [core-mark-required]="question.required">
<strong>{{question.num}}.</strong> {{ question.text }}
</span>
</ion-label>
</ion-col>
<ion-col size="7">
<ion-label id="addon-mod_survey-{{question.id}}">
<span [core-mark-required]="question.required">
<strong>{{question.num}}.</strong> {{ question.text }}
</span>
</ion-label>
</ion-col>
<!-- Tablet view: radio buttons -->
<ion-col class="ion-hide-md-down ion-text-center" size="1"
*ngFor="let option of question.optionsArray; let value=index;"
>
<!-- Empty slot to avoid errors on migration tslint checks -->
<ion-radio [value]="value + 1" [attr.aria-label]="question.num + '. '+question.text + ': ' + option">
</ion-radio>
</ion-col>
<ion-col class="ion-hide-md-up" size="5">
<ion-select class="ion-padding" [(ngModel)]="answers[question.name]" [required]="question.required"
[attr.aria-labelledby]="'addon-mod_survey-'+question.id" interface="action-sheet"
[name]="question.name">
<ion-select-option value="-1" selected disabled>{{ 'core.choose' | translate }}</ion-select-option>
<ion-select-option *ngFor="let option of question.optionsArray; let value=index;"
[value]="value +1">
{{option}}
</ion-select-option>
</ion-select>
</ion-col>
</ion-row>
</ion-radio-group>
<!-- Tablet view: radio buttons -->
<ion-col class="ion-hide-md-down ion-text-center" size="1"
*ngFor="let option of question.optionsArray; let value=index;"
>
<!-- Empty slot to avoid errors on migration tslint checks -->
<ion-radio [value]="value + 1" [attr.aria-label]="question.num + '. '+question.text + ': ' + option">
</ion-radio>
</ion-col>
<ion-col class="ion-hide-md-up" size="5">
<ion-select class="ion-padding" [(ngModel)]="answers[question.name]" [required]="question.required"
[attr.aria-labelledby]="'addon-mod_survey-'+question.id" interface="action-sheet"
[name]="question.name">
<ion-select-option value="-1" selected disabled>{{ 'core.choose' | translate }}</ion-select-option>
<ion-select-option *ngFor="let option of question.optionsArray; let value=index;"
[value]="value +1">
{{option}}
</ion-select-option>
</ion-select>
</ion-col>
</ion-row>
</ion-radio-group>
</ng-container>
<!-- Single question (don't belong to a category) -->
<ng-container *ngIf="(!question.multiArray || question.multiArray.length == 0) && question.parent === 0">

View File

@ -67,7 +67,7 @@ export class AddonModSurveyPrefetchHandlerService extends CoreCourseActivityPref
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchSurvey.bind(this, module, courseId));
}

View File

@ -130,7 +130,7 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
/**
* @inheritdoc
*/
async prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean): Promise<void> {
async prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise<void> {
// Get the download time of the package before starting the download (otherwise we'd always get current time).
const siteId = CoreSites.getCurrentSiteId();
@ -138,7 +138,12 @@ export class AddonModWikiPrefetchHandlerService extends CoreCourseActivityPrefet
const downloadTime = data?.downloadTime || 0;
return this.prefetchPackage(module, courseId, this.prefetchWiki.bind(this, module, courseId, single, downloadTime, siteId));
return this.prefetchPackage(
module,
courseId,
this.prefetchWiki.bind(this, module, courseId, !!single, downloadTime),
siteId,
);
}
/**

View File

@ -210,7 +210,7 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number): Promise<void> {
prefetch(module: CoreCourseAnyModuleData, courseId: number): Promise<void> {
return this.prefetchPackage(module, courseId, this.prefetchWorkshop.bind(this, module, courseId));
}
@ -258,9 +258,6 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr
* @return Promise resolved when done.
*/
protected async prefetchWorkshop(module: CoreCourseAnyModuleData, courseId: number, siteId: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
const userIds: number[] = [];
const commonOptions = {
readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK,

View File

@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonNotificationsMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes {
return [
{
path: 'list',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonNotificationsMainMenuHandlerService.PAGE_NAME,
},
loadChildren: () => import('./pages/list/list.module').then(m => m.AddonNotificationsListPageModule),
},

View File

@ -16,13 +16,14 @@ import { Injector, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonPrivateFilesMainMenuHandlerService } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes {
return [
{
path: 'root',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: AddonPrivateFilesMainMenuHandlerService.PAGE_NAME,
},
loadChildren: () => import('./pages/index/index.module').then(m => m.AddonPrivateFilesIndexPageModule),
},

View File

@ -78,8 +78,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
*/
async prefetchPackage(
module: CoreCourseAnyModuleData,
courseId: number | undefined,
downloadFunction: () => Promise<string>,
courseId: number,
downloadFunction: (siteId: string) => Promise<string>,
siteId?: string,
): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
@ -111,8 +111,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
protected async changeStatusAndPrefetch(
module: CoreCourseAnyModuleData,
courseId: number | undefined,
downloadFunction: () => Promise<string>,
siteId?: string,
downloadFunction: (siteId: string) => Promise<string>,
siteId: string,
): Promise<void> {
try {
await this.setDownloading(module.id, siteId);
@ -125,7 +125,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe
]);
// Call the download function.
let extra = await downloadFunction();
let extra = await downloadFunction(siteId);
// Only accept string types.
if (typeof extra != 'string') {

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreError } from '@classes/errors/error';
import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreApp } from '@services/app';
@ -191,12 +190,7 @@ export class CoreCourseResourcePrefetchHandlerBase extends CoreCourseModulePrefe
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
*/
prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise<void> {
courseId = courseId || module.course;
if (!courseId) {
throw new CoreError('Course ID not supplied.');
}
prefetch(module: CoreCourseWSModule, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
return this.downloadOrPrefetch(module, courseId, true, dirPath);
}

View File

@ -182,7 +182,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
if (!CoreFilepool.getPackageDownloadPromise(siteId, handler.component, module.id)) {
// Not handled, the app was probably restarted or something weird happened.
// Re-start download (files already on queue or already downloaded will be skipped).
handler.prefetch(module);
handler.prefetch(module, module.course!);
}
} else if (handler.determineStatus) {
// The handler implements a determineStatus function. Apply it.
@ -1403,7 +1403,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
* @param dirPath Path of the directory where to store all the content files.
* @return Promise resolved when done.
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void>;
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise<void>;
/**
* Download the module.

View File

@ -23,10 +23,14 @@ 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 { CoreGradesMainMenuHandlerService } from './services/handlers/mainmenu';
const mobileRoutes: Routes = [
{
path: '',
data: {
mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME,
},
component: CoreGradesCoursesPage,
},
{
@ -42,6 +46,9 @@ const mobileRoutes: Routes = [
const tabletRoutes: Routes = [
{
path: '',
data: {
mainMenuTabRoot: CoreGradesMainMenuHandlerService.PAGE_NAME,
},
component: CoreGradesCoursesPage,
children: [
{

View File

@ -21,6 +21,7 @@ import { CoreSharedModule } from '@/core/shared.module';
import { CoreMainMenuHomePage } from './home';
import { MAIN_MENU_HOME_ROUTES } from './home-routing.module';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreMainMenuHomeHandlerService } from '@features/mainmenu/services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES);
@ -29,7 +30,7 @@ function buildRoutes(injector: Injector): Routes {
...buildTabMainRoutes(injector, {
path: '',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: CoreMainMenuHomeHandlerService.PAGE_NAME,
},
component: CoreMainMenuHomePage,
children: routes.children,

View File

@ -176,12 +176,12 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
e.stopImmediatePropagation();
// Current tab was clicked. Check if user is already at root level.
const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } });
if (mainMenuRootRoute) {
const isMainMenuRoot = await this.currentRouteIsMainMenuRoot();
if (isMainMenuRoot) {
return; // Already at root level, nothing to do.
}
// Current route doesn't define isMainMenuRoot. Check if the current path is the tab one.
// Maybe the route isn't defined as it should. Check if the current path is the tab one.
const currentPath = CoreNavigator.getCurrentPath();
if (currentPath == `/main/${page}`) {
return; // Already at root level, nothing to do.
@ -227,8 +227,8 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
event.detail.register(-10, async (processNextHandler: () => void) => {
// This callback can be called at the same time as Ionic's back navigation callback.
// Check if user is already at the root of a tab.
const mainMenuRootRoute = CoreNavigator.getCurrentRoute({ routeData: { isMainMenuRoot: true } });
if (!mainMenuRootRoute) {
const isMainMenuRoot = await this.currentRouteIsMainMenuRoot();
if (!isMainMenuRoot) {
return; // Not at root level, let Ionic handle the navigation.
}
@ -257,6 +257,16 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
});
}
/**
* Check if current route is the root of the current main menu tab.
*
* @return Promise.
*/
protected async currentRouteIsMainMenuRoot(): Promise<boolean> {
// Check if the current route is the root of the current main menu tab.
return !!CoreNavigator.getCurrentRoute({ routeData: { mainMenuTabRoot: CoreNavigator.getCurrentMainMenuTab() } });
}
}
/**

View File

@ -18,6 +18,7 @@ import { RouterModule, ROUTES } from '@angular/router';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreMainMenuMorePage } from './more';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreMainMenuProvider } from '@features/mainmenu/services/mainmenu';
@NgModule({
imports: [
@ -31,7 +32,7 @@ import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.modu
useFactory: (injector: Injector) => buildTabMainRoutes(injector, {
component: CoreMainMenuMorePage,
data: {
isMainMenuRoot: true,
mainMenuTabRoot: CoreMainMenuProvider.MORE_PAGE_NAME,
},
}),
},

View File

@ -222,14 +222,11 @@ export class CoreSitePluginsModulePrefetchHandler extends CoreCourseActivityPref
/**
* @inheritdoc
*/
prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise<void> {
const siteId = CoreSites.getCurrentSiteId();
prefetch(module: CoreCourseAnyModuleData, courseId: number, single?: boolean, dirPath?: string): Promise<void> {
return this.prefetchPackage(
module,
courseId,
this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath, siteId),
siteId,
this.downloadPrefetchPlugin.bind(this, module, courseId, true, dirPath),
);
}

View File

@ -16,6 +16,7 @@ import { Injector, NgModule } from '@angular/core';
import { Route, RouterModule, ROUTES, Routes } from '@angular/router';
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreTagMainMenuHandlerService } from './services/handlers/mainmenu';
export const CoreTagIndexAreaRoute: Route = {
path: 'index-area',
@ -32,7 +33,7 @@ function buildRoutes(injector: Injector): Routes {
{
path: 'search',
data: {
isMainMenuRoot: true,
mainMenuTabRoot: CoreTagMainMenuHandlerService.PAGE_NAME,
},
loadChildren: () => import('@features/tag//pages/search/search.page.module').then(m => m.CoreTagSearchPageModule),
},

View File

@ -629,6 +629,10 @@ export class CoreAppProvider {
* @param color RGB color to use as status bar background. If not set the css variable will be read.
*/
setStatusBarColor(color?: string): void {
if (!this.isMobile()) {
return;
}
if (!color) {
// Get the default color to change it.
const element = document.querySelector('ion-header ion-toolbar');