forked from EVOgeek/Vmeda.Online
		
	MOBILE-3039 course: Hide download when offline disabled
This commit is contained in:
		
							parent
							
								
									240f425d97
								
							
						
					
					
						commit
						ea22e6556f
					
				| @ -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> | ||||
| @ -36,7 +36,7 @@ | ||||
|         <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> | ||||
|  | ||||
| @ -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.'; | ||||
| 
 | ||||
| @ -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()); | ||||
| @ -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(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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'; | ||||
| 
 | ||||
| /** | ||||
| @ -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'); | ||||
| @ -50,6 +53,8 @@ export class CoreCourseListModTypePage { | ||||
|      * View loaded. | ||||
|      */ | ||||
|     ionViewDidLoad(): void { | ||||
|         this.downloadEnabled = !this.sitesProvider.getCurrentSite().isOfflineDisabled(); | ||||
| 
 | ||||
|         this.fetchData().finally(() => { | ||||
|             this.loaded = true; | ||||
|         }); | ||||
|  | ||||
| @ -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.
 | ||||
|  | ||||
| @ -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'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -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'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -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. --> | ||||
|  | ||||
| @ -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, | ||||
| @ -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; | ||||
|         }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user