Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-item-divider>
<h2>{{ 'addon.block_myoverview.pluginname' | translate }}</h2>
<!-- Download all courses. -->
<div *ngIf="downloadEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1 && !showFilter" class="core-button-spinner" item-end>
<div *ngIf="downloadCoursesEnabled && downloadEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1 && !showFilter" class="core-button-spinner" item-end>
<button *ngIf="prefetchCoursesData[selectedFilter].icon && prefetchCoursesData[selectedFilter].icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
<core-icon [name]="prefetchCoursesData[selectedFilter].icon"></core-icon>
</button>
Expand Down Expand Up @@ -36,7 +36,7 @@ <h2>{{ 'addon.block_myoverview.pluginname' | translate }}</h2>
<ion-grid no-padding>
<ion-row no-padding>
<ion-col *ngFor="let course of filteredCourses" no-padding col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 align-self-stretch>
<core-courses-course-progress [course]="course" class="core-courseoverview" showAll="true" [showDownload]="downloadEnabled"></core-courses-course-progress>
<core-courses-course-progress [course]="course" class="core-courseoverview" showAll="true" [showDownload]="downloadCourseEnabled && downloadEnabled"></core-courses-course-progress>
</ion-col>
</ion-row>
</ion-grid>
Expand Down
14 changes: 14 additions & 0 deletions src/addon/block/myoverview/components/myoverview/myoverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
showHidden = false;
showSelectorFilter = false;
showSortFilter = false;
downloadCourseEnabled: boolean;
downloadCoursesEnabled: boolean;

protected prefetchIconsInitialized = false;
protected isDestroyed;
protected downloadButtonObserver;
protected coursesObserver;
protected updateSiteObserver;
protected courseIds = [];
protected fetchContentDefaultError = 'Error getting my overview data.';

Expand Down Expand Up @@ -96,6 +99,16 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
}
});

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.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !this.coursesProvider.isDownloadCoursesDisabledInSite();

}, this.sitesProvider.getCurrentSiteId());

this.coursesObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, () => {
this.refreshContent();
}, this.sitesProvider.getCurrentSiteId());
Expand Down Expand Up @@ -336,6 +349,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
ngOnDestroy(): void {
this.isDestroyed = true;
this.coursesObserver && this.coursesObserver.off();
this.updateSiteObserver && this.updateSiteObserver.off();
this.downloadButtonObserver && this.downloadButtonObserver.off();
}
}
2 changes: 1 addition & 1 deletion src/core/course/pages/list-mod-type/list-mod-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ion-list>
<ng-container *ngFor="let module of modules">
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [courseId]="courseId" downloadEnabled="true"></core-course-module>
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [courseId]="courseId" [downloadEnabled]="downloadEnabled"></core-course-module>
</ng-container>
</ion-list>
</core-loading>
Expand Down
7 changes: 6 additions & 1 deletion src/core/course/pages/list-mod-type/list-mod-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreCourseProvider } from '../../providers/course';
import { CoreCourseModuleDelegate } from '../../providers/module-delegate';
import { CoreCourseHelperProvider } from '../../providers/helper';
import { CoreSitesProvider } from '@providers/sites';
import { CoreConstants } from '@core/constants';

/**
Expand All @@ -33,13 +34,15 @@ export class CoreCourseListModTypePage {
modules = [];
title: string;
loaded = false;
downloadEnabled = false;

protected courseId: number;
protected modName: string;
protected archetypes = {}; // To speed up the check of modules.

constructor(navParams: NavParams, private courseProvider: CoreCourseProvider, private moduleDelegate: CoreCourseModuleDelegate,
private domUtils: CoreDomUtilsProvider, private courseHelper: CoreCourseHelperProvider) {
private domUtils: CoreDomUtilsProvider, private courseHelper: CoreCourseHelperProvider,
private sitesProvider: CoreSitesProvider) {

this.title = navParams.get('title');
this.courseId = navParams.get('courseId');
Expand All @@ -50,6 +53,8 @@ export class CoreCourseListModTypePage {
* View loaded.
*/
ionViewDidLoad(): void {
this.downloadEnabled = !this.sitesProvider.getCurrentSite().isOfflineDisabled();

this.fetchData().finally(() => {
this.loaded = true;
});
Expand Down
3 changes: 2 additions & 1 deletion src/core/course/pages/section/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export class CoreCourseSectionPage implements OnDestroy {

// Get the title to display. We dont't have sections yet.
this.title = courseFormatDelegate.getCourseTitle(this.course);
this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course);
this.displayEnableDownload = !sitesProvider.getCurrentSite().isOfflineDisabled() &&
courseFormatDelegate.displayEnableDownload(this.course);
this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();

// Check if the course format requires the view to be refreshed when completion changes.
Expand Down
4 changes: 2 additions & 2 deletions src/core/courses/providers/courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class CoreCoursesProvider {
isDownloadCourseDisabledInSite(site?: CoreSite): boolean {
site = site || this.sitesProvider.getCurrentSite();

return site.isFeatureDisabled('NoDelegate_CoreCourseDownload');
return site.isOfflineDisabled() || site.isFeatureDisabled('NoDelegate_CoreCourseDownload');
}

/**
Expand All @@ -191,7 +191,7 @@ export class CoreCoursesProvider {
isDownloadCoursesDisabledInSite(site?: CoreSite): boolean {
site = site || this.sitesProvider.getCurrentSite();

return site.isFeatureDisabled('NoDelegate_CoreCoursesDownload');
return site.isOfflineDisabled() || site.isFeatureDisabled('NoDelegate_CoreCoursesDownload');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<core-format-text [text]="section.summary"></core-format-text>
</ion-item>

<core-course-module *ngFor="let module of section.modules" [module]="module" [courseId]="siteHomeId" [downloadEnabled]="true" [section]="section"></core-course-module>
<core-course-module *ngFor="let module of section.modules" [module]="module" [courseId]="siteHomeId" [downloadEnabled]="downloadEnabled" [section]="section"></core-course-module>
</ng-container>

<!-- Site home items: news, categories, courses, etc. -->
Expand Down
2 changes: 2 additions & 0 deletions src/core/sitehome/components/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class CoreSiteHomeIndexComponent implements OnInit {
siteHomeId: number;
currentSite: CoreSite;
blocks = [];
downloadEnabled: boolean;

constructor(private domUtils: CoreDomUtilsProvider, sitesProvider: CoreSitesProvider,
private courseProvider: CoreCourseProvider, private courseHelper: CoreCourseHelperProvider,
Expand All @@ -52,6 +53,7 @@ export class CoreSiteHomeIndexComponent implements OnInit {
* Component being initialized.
*/
ngOnInit(): void {
this.downloadEnabled = !this.currentSite.isOfflineDisabled();
this.loadContent().finally(() => {
this.dataLoaded = true;
});
Expand Down