MOBILE-2795 course: Fix disable download course

main
Dani Palou 2019-01-04 15:29:27 +01:00
parent 987ff6ad43
commit c5440811dd
3 changed files with 6 additions and 3 deletions

View File

@ -22,7 +22,7 @@
<div class="core-button-spinner" *ngIf="courseOptionMenuEnabled">
<!-- Download course spinner. -->
<ion-spinner *ngIf="prefetchCourseData.prefetchCourseIcon == 'spinner' || showSpinner"></ion-spinner>
<ion-spinner *ngIf="(downloadCourseEnabled && prefetchCourseData.prefetchCourseIcon == 'spinner') || showSpinner"></ion-spinner>
<!-- Options menu. -->
<button ion-button icon-only clear color="dark" (click)="showCourseOptionsMenu($event)" *ngIf="!showSpinner">

View File

@ -7,7 +7,7 @@
<ion-icon name="search"></ion-icon>
</button>
<core-context-menu>
<core-context-menu-item *ngIf="downloadCourseEnabled" [priority]="1000" [content]="'core.settings.showdownloadoptions' | translate" (action)="toggleDownload()" [iconAction]="downloadEnabledIcon"></core-context-menu-item>
<core-context-menu-item *ngIf="downloadCourseEnabled || downloadCoursesEnabled" [priority]="1000" [content]="'core.settings.showdownloadoptions' | translate" (action)="toggleDownload()" [iconAction]="downloadEnabledIcon"></core-context-menu-item>
</core-context-menu>
</ion-buttons>
</ion-navbar>

View File

@ -52,6 +52,7 @@ export class CoreCoursesDashboardPage implements OnDestroy {
downloadEnabled: boolean;
downloadEnabledIcon = 'square-outline'; // Disabled by default.
downloadCourseEnabled: boolean;
downloadCoursesEnabled: boolean;
protected isDestroyed;
protected updateSiteObserver;
@ -69,11 +70,13 @@ export class CoreCoursesDashboardPage implements OnDestroy {
ionViewDidLoad(): void {
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !this.coursesProvider.isDownloadCoursesDisabledInSite();
// Refresh the enabled flags if site is updated.
this.updateSiteObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => {
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !this.coursesProvider.isDownloadCoursesDisabledInSite();
this.switchDownload(this.downloadEnabled);
@ -196,7 +199,7 @@ export class CoreCoursesDashboardPage implements OnDestroy {
* @param {boolean} enable If enable or disable.
*/
protected switchDownload(enable: boolean): void {
this.downloadEnabled = this.downloadCourseEnabled && enable;
this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && enable;
this.downloadEnabledIcon = this.downloadEnabled ? 'checkbox-outline' : 'square-outline';
this.eventsProvider.trigger(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED, {enabled: this.downloadEnabled});
}