Merge pull request #2027 from marxjohnson/MOBILE-3092_integration

MOBILE-3092 dashboard: Disable empty options in course selector
main
Juan Leyva 2019-07-31 13:37:04 +02:00 committed by GitHub
commit 12bd945801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -19,11 +19,11 @@
<!-- "Time" selector. --> <!-- "Time" selector. -->
<ion-select text-start [title]="'core.show' | translate" [(ngModel)]="selectedFilter" (ngModelChange)="selectedChanged()" interface="popover" class="core-button-select"> <ion-select text-start [title]="'core.show' | translate" [(ngModel)]="selectedFilter" (ngModelChange)="selectedChanged()" interface="popover" class="core-button-select">
<ion-option value="all">{{ 'addon.block_myoverview.all' | translate }}</ion-option> <ion-option value="all">{{ 'addon.block_myoverview.all' | translate }}</ion-option>
<ion-option value="inprogress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option> <ion-option value="inprogress" [disabled]="disableInProgress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
<ion-option value="future">{{ 'addon.block_myoverview.future' | translate }}</ion-option> <ion-option value="future" [disabled]="disableFuture">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
<ion-option value="past">{{ 'addon.block_myoverview.past' | translate }}</ion-option> <ion-option value="past" [disabled]="disablePast">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
<ion-option value="favourite" *ngIf="showFavourite">{{ 'addon.block_myoverview.favourites' | translate }}</ion-option> <ion-option value="favourite" *ngIf="showFavourite" [disabled]="disableFavourite">{{ 'addon.block_myoverview.favourites' | translate }}</ion-option>
<ion-option value="hidden" *ngIf="showHidden">{{ 'addon.block_myoverview.hiddencourses' | translate }}</ion-option> <ion-option value="hidden" *ngIf="showHidden" [disabled]="disableHidden">{{ 'addon.block_myoverview.hiddencourses' | translate }}</ion-option>
</ion-select> </ion-select>
</div> </div>
<core-empty-box *ngIf="courses[selectedFilter].length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocourses' | translate"></core-empty-box> <core-empty-box *ngIf="courses[selectedFilter].length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocourses' | translate"></core-empty-box>

View File

@ -64,6 +64,11 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
showSortFilter = false; showSortFilter = false;
downloadCourseEnabled: boolean; downloadCourseEnabled: boolean;
downloadCoursesEnabled: boolean; downloadCoursesEnabled: boolean;
disableInProgress = false;
disablePast = false;
disableFuture = false;
disableFavourite = false;
disableHidden = false;
protected prefetchIconsInitialized = false; protected prefetchIconsInitialized = false;
protected isDestroyed; protected isDestroyed;
@ -170,12 +175,17 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
this.courses.filter = ''; this.courses.filter = '';
this.showFilter = false; 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 || 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.showHidden = this.showSelectorFilter && typeof courses[0].hidden != 'undefined';
this.disableHidden = this.courses.hidden.length === 0;
this.showFavourite = this.showSelectorFilter && typeof courses[0].isfavourite != 'undefined'; this.showFavourite = this.showSelectorFilter && typeof courses[0].isfavourite != 'undefined';
if (!this.showSelectorFilter) { this.disableFavourite = this.courses.favourite.length === 0;
// No selector, show all. if (!this.showSelectorFilter || (this.selectedFilter === 'inprogress' && this.disableInProgress)) {
// No selector, or the default option is disabled, show all.
this.selectedFilter = 'all'; this.selectedFilter = 'all';
} }
this.filteredCourses = this.courses[this.selectedFilter]; this.filteredCourses = this.courses[this.selectedFilter];