From 627e25593a6c985047fc5292d2711b9b427893c9 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 1 Jul 2019 11:58:19 +0100 Subject: [PATCH] MOBILE-3092 dashboard: Disable empty options in course selector --- .../myoverview/addon-block-myoverview.html | 10 +++++----- .../components/myoverview/myoverview.ts | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html b/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html index 598c204f0..294a499c4 100644 --- a/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html +++ b/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html @@ -19,11 +19,11 @@ {{ 'addon.block_myoverview.all' | translate }}∫ - {{ 'addon.block_myoverview.inprogress' | translate }} - {{ 'addon.block_myoverview.future' | translate }} - {{ 'addon.block_myoverview.past' | translate }} - {{ 'addon.block_myoverview.favourites' | translate }} - {{ 'addon.block_myoverview.hiddencourses' | translate }} + {{ 'addon.block_myoverview.inprogress' | translate }} + {{ 'addon.block_myoverview.future' | translate }} + {{ 'addon.block_myoverview.past' | translate }} + {{ 'addon.block_myoverview.favourites' | translate }} + {{ 'addon.block_myoverview.hiddencourses' | translate }} diff --git a/src/addon/block/myoverview/components/myoverview/myoverview.ts b/src/addon/block/myoverview/components/myoverview/myoverview.ts index b36202f7e..4848e4d5c 100644 --- a/src/addon/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addon/block/myoverview/components/myoverview/myoverview.ts @@ -64,6 +64,11 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem showSortFilter = false; downloadCourseEnabled: boolean; downloadCoursesEnabled: boolean; + disableInProgress = false; + disablePast = false; + disableFuture = false; + disableFavourite = false; + disableHidden = false; protected prefetchIconsInitialized = false; protected isDestroyed; @@ -173,12 +178,17 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem this.courses.filter = ''; this.showFilter = false; + this.disableInProgress = this.courses.inprogress.length === 0; + this.disablePast = this.courses.past.length === 0; + this.disableFuture = this.courses.future.length === 0; this.showSelectorFilter = courses.length > 0 && (this.courses.past.length > 0 || this.courses.future.length > 0 || - typeof courses[0].enddate != 'undefined'); + typeof courses[0].enddate != 'undefined'); this.showHidden = this.showSelectorFilter && typeof courses[0].hidden != 'undefined'; + this.disableHidden = this.courses.hidden.length === 0; this.showFavourite = this.showSelectorFilter && typeof courses[0].isfavourite != 'undefined'; - if (!this.showSelectorFilter) { - // No selector, show all. + this.disableFavourite = this.courses.favourite.length === 0; + if (!this.showSelectorFilter || (this.selectedFilter === 'inprogress' && this.disableInProgress)) { + // No selector, or the default option is disabled, show all. this.selectedFilter = 'all'; } this.filteredCourses = this.courses[this.selectedFilter];