From 4c304af5e60a2500fe1428fc80b2b71099b9fda1 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 31 May 2021 10:32:03 +0200 Subject: [PATCH 1/2] MOBILE-3320 block: Fix only title blocks not changing tabs --- src/addons/block/calendarmonth/services/block-handler.ts | 3 +++ .../block/calendarupcoming/services/block-handler.ts | 3 +++ src/addons/block/learningplans/services/block-handler.ts | 3 +++ src/addons/block/privatefiles/services/block-handler.ts | 5 ++++- src/core/features/block/classes/base-block-component.ts | 2 ++ src/core/features/block/components/block/block.ts | 1 + .../block/components/only-title-block/only-title-block.ts | 7 ++++++- src/core/features/block/services/block-delegate.ts | 6 ++++++ 8 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/addons/block/calendarmonth/services/block-handler.ts b/src/addons/block/calendarmonth/services/block-handler.ts index a2149dfde..bf557dbdc 100644 --- a/src/addons/block/calendarmonth/services/block-handler.ts +++ b/src/addons/block/calendarmonth/services/block-handler.ts @@ -47,6 +47,9 @@ export class AddonBlockCalendarMonthHandlerService extends CoreBlockBaseHandler component: CoreBlockOnlyTitleComponent, link: AddonCalendar.getMainCalendarPagePath(), linkParams: linkParams, + navOptions: { + preferCurrentTab: false, + }, }; } diff --git a/src/addons/block/calendarupcoming/services/block-handler.ts b/src/addons/block/calendarupcoming/services/block-handler.ts index a965176a4..ac1c0dd77 100644 --- a/src/addons/block/calendarupcoming/services/block-handler.ts +++ b/src/addons/block/calendarupcoming/services/block-handler.ts @@ -47,6 +47,9 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl component: CoreBlockOnlyTitleComponent, link: AddonCalendar.getMainCalendarPagePath(), linkParams: linkParams, + navOptions: { + preferCurrentTab: false, + }, }; } diff --git a/src/addons/block/learningplans/services/block-handler.ts b/src/addons/block/learningplans/services/block-handler.ts index 38afe6a04..2ab12f1a1 100644 --- a/src/addons/block/learningplans/services/block-handler.ts +++ b/src/addons/block/learningplans/services/block-handler.ts @@ -39,6 +39,9 @@ export class AddonBlockLearningPlansHandlerService extends CoreBlockBaseHandler class: 'addon-block-learning-plans', component: CoreBlockOnlyTitleComponent, link: AddonCompetencyMainMenuHandlerService.PAGE_NAME, + navOptions: { + preferCurrentTab: false, + }, }; } diff --git a/src/addons/block/privatefiles/services/block-handler.ts b/src/addons/block/privatefiles/services/block-handler.ts index 6774dd018..73c160eaf 100644 --- a/src/addons/block/privatefiles/services/block-handler.ts +++ b/src/addons/block/privatefiles/services/block-handler.ts @@ -39,8 +39,11 @@ export class AddonBlockPrivateFilesHandlerService extends CoreBlockBaseHandler { title: 'addon.block_privatefiles.pluginname', class: 'addon-block-private-files', component: CoreBlockOnlyTitleComponent, - link: '/main/' + AddonPrivateFilesMainMenuHandlerService.PAGE_NAME, + link: AddonPrivateFilesMainMenuHandlerService.PAGE_NAME, linkParams: { root: 'my' }, + navOptions: { + preferCurrentTab: false, + }, }; } diff --git a/src/core/features/block/classes/base-block-component.ts b/src/core/features/block/classes/base-block-component.ts index d209fd191..ea29a2bb2 100644 --- a/src/core/features/block/classes/base-block-component.ts +++ b/src/core/features/block/classes/base-block-component.ts @@ -21,6 +21,7 @@ import { CoreCourseBlock } from '../../course/services/course'; import { IonRefresher } from '@ionic/angular'; import { Params } from '@angular/router'; import { ContextLevel } from '@/core/constants'; +import { CoreNavigationOptions } from '@services/navigator'; /** * Template class to easily create components for blocks. @@ -36,6 +37,7 @@ export abstract class CoreBlockBaseComponent implements OnInit { @Input() instanceId!: number; // The instance ID associated with the context level. @Input() link?: string; // Link to go when clicked. @Input() linkParams?: Params; // Link params to go when clicked. + @Input() navOptions?: CoreNavigationOptions; // Navigation options. loaded = false; // If the component has been loaded. protected fetchContentDefaultError = ''; // Default error to show when loading contents. diff --git a/src/core/features/block/components/block/block.ts b/src/core/features/block/components/block/block.ts index 2fe6f2a44..75a6aa64e 100644 --- a/src/core/features/block/components/block/block.ts +++ b/src/core/features/block/components/block/block.ts @@ -115,6 +115,7 @@ export class CoreBlockComponent implements OnInit, OnDestroy, DoCheck { instanceId: this.instanceId, link: data.link || null, linkParams: data.linkParams || null, + navOptions: data.navOptions || null, }, this.extraData || {}, data.componentData || {}); } catch { // Ignore errors. diff --git a/src/core/features/block/components/only-title-block/only-title-block.ts b/src/core/features/block/components/only-title-block/only-title-block.ts index a0be90b78..47169f3c7 100644 --- a/src/core/features/block/components/only-title-block/only-title-block.ts +++ b/src/core/features/block/components/only-title-block/only-title-block.ts @@ -43,7 +43,12 @@ export class CoreBlockOnlyTitleComponent extends CoreBlockBaseComponent implemen * Go to the block page. */ gotoBlock(): void { - CoreNavigator.navigateToSitePath(this.link!, { params: this.linkParams }); + const navOptions = this.navOptions || {}; + if (this.linkParams) { + navOptions.params = this.linkParams; + } + + CoreNavigator.navigateToSitePath(this.link!, navOptions); } } diff --git a/src/core/features/block/services/block-delegate.ts b/src/core/features/block/services/block-delegate.ts index 67e80bb65..481fdfaa2 100644 --- a/src/core/features/block/services/block-delegate.ts +++ b/src/core/features/block/services/block-delegate.ts @@ -21,6 +21,7 @@ import { CoreCourseBlock } from '@features/course/services/course'; import { Params } from '@angular/router'; import { makeSingleton } from '@singletons'; import { CoreBlockDefaultHandler } from './handlers/default-block'; +import { CoreNavigationOptions } from '@services/navigator'; /** * Interface that all blocks must implement. @@ -80,6 +81,11 @@ export interface CoreBlockHandlerData { * Params of the link. */ linkParams?: Params; + + /** + * Navigation options. + */ + navOptions?: CoreNavigationOptions; } /** From 92b3dbe225efca3149852c086d8f4879e7eb0c5e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 31 May 2021 12:43:56 +0200 Subject: [PATCH 2/2] MOBILE-3320 course: Fix section download status calculation --- src/core/features/course/services/module-prefetch-delegate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index f315b6917..bf2e33a06 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -735,7 +735,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate