Merge pull request #2027 from marxjohnson/MOBILE-3092_integration
MOBILE-3092 dashboard: Disable empty options in course selectormain
commit
12bd945801
|
@ -19,11 +19,11 @@
|
|||
<!-- "Time" selector. -->
|
||||
<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="inprogress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
|
||||
<ion-option value="future">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
|
||||
<ion-option value="past">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
|
||||
<ion-option value="favourite" *ngIf="showFavourite">{{ 'addon.block_myoverview.favourites' | translate }}</ion-option>
|
||||
<ion-option value="hidden" *ngIf="showHidden">{{ 'addon.block_myoverview.hiddencourses' | translate }}</ion-option>
|
||||
<ion-option value="inprogress" [disabled]="disableInProgress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
|
||||
<ion-option value="future" [disabled]="disableFuture">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
|
||||
<ion-option value="past" [disabled]="disablePast">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
|
||||
<ion-option value="favourite" *ngIf="showFavourite" [disabled]="disableFavourite">{{ 'addon.block_myoverview.favourites' | translate }}</ion-option>
|
||||
<ion-option value="hidden" *ngIf="showHidden" [disabled]="disableHidden">{{ 'addon.block_myoverview.hiddencourses' | translate }}</ion-option>
|
||||
</ion-select>
|
||||
</div>
|
||||
<core-empty-box *ngIf="courses[selectedFilter].length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocourses' | translate"></core-empty-box>
|
||||
|
|
|
@ -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;
|
||||
|
@ -170,12 +175,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];
|
||||
|
|
Loading…
Reference in New Issue