forked from EVOgeek/Vmeda.Online
		
	MOBILE-3954 blocks: Remove download enable switch from block pages
This commit is contained in:
		
							parent
							
								
									c59ca185b6
								
							
						
					
					
						commit
						94fbd9e0e2
					
				| @ -4,7 +4,7 @@ | ||||
|     </ion-label> | ||||
|     <div slot="end" class="flex-row"> | ||||
|         <!-- Download all courses. --> | ||||
|         <div *ngIf="downloadCoursesEnabled && downloadEnabled && filteredCourses.length > 1" class="core-button-spinner"> | ||||
|         <div *ngIf="downloadCoursesEnabled && filteredCourses.length > 1" class="core-button-spinner"> | ||||
|             <ion-button *ngIf="!prefetchCoursesData.loading" fill="clear" color="dark" (click)="prefetchCourses()" | ||||
|                 [attr.aria-label]="prefetchCoursesData.statusTranslatable | translate"> | ||||
|                 <ion-icon [name]="prefetchCoursesData.icon" slot="icon-only" aria-hidden="true"> | ||||
| @ -77,8 +77,8 @@ | ||||
|             <ion-row class="ion-no-padding"> | ||||
|                 <ion-col *ngFor="let course of filteredCourses" class="ion-no-padding" size="12" size-sm="6" size-md="6" size-lg="4" | ||||
|                     size-xl="3"> | ||||
|                     <core-courses-course-list-item [course]="course" class="core-courseoverview" | ||||
|                         [showDownload]="downloadCourseEnabled && downloadEnabled" [layout]="layouts.selected"> | ||||
|                     <core-courses-course-list-item [course]="course" class="core-courseoverview" [showDownload]="downloadCourseEnabled" | ||||
|                         [layout]="layouts.selected"> | ||||
|                     </core-courses-course-list-item> | ||||
|                 </ion-col> | ||||
|             </ion-row> | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, Input, OnDestroy, OnChanges, SimpleChange } from '@angular/core'; | ||||
| import { Component, OnInit, OnDestroy } from '@angular/core'; | ||||
| import { ModalOptions } from '@ionic/core'; | ||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||
| import { CoreTimeUtils } from '@services/utils/time'; | ||||
| @ -40,9 +40,7 @@ const FILTER_PRIORITY: AddonBlockMyOverviewTimeFilters[] = ['all', 'inprogress', | ||||
|     selector: 'addon-block-myoverview', | ||||
|     templateUrl: 'addon-block-myoverview.html', | ||||
| }) | ||||
| export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implements OnInit, OnChanges, OnDestroy { | ||||
| 
 | ||||
|     @Input() downloadEnabled = false; | ||||
| export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy { | ||||
| 
 | ||||
|     filteredCourses: CoreEnrolledCourseDataWithOptions[] = []; | ||||
| 
 | ||||
| @ -197,16 +195,6 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     ngOnChanges(changes: {[name: string]: SimpleChange}): void { | ||||
|         if (changes.downloadEnabled && !changes.downloadEnabled.previousValue && this.downloadEnabled && this.loaded) { | ||||
|             // Download all courses is enabled now, initialize it.
 | ||||
|             this.initPrefetchCoursesIcons(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
| @ -431,7 +419,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem | ||||
|      * @return Promise resolved when done. | ||||
|      */ | ||||
|     async initPrefetchCoursesIcons(): Promise<void> { | ||||
|         if (this.prefetchIconsInitialized || !this.downloadEnabled) { | ||||
|         if (this.prefetchIconsInitialized) { | ||||
|             // Already initialized.
 | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @ -16,8 +16,8 @@ | ||||
|         <div (onResize)="scrollControls.updateScrollPosition()" class="flex-row"> | ||||
|             <div class="safe-area-pseudo-padding-start"></div> | ||||
|             <ng-container *ngFor="let course of courses"> | ||||
|                 <core-courses-course-list-item [course]="course" class="core-recentlyaccessedcourses" layout="summarycard" | ||||
|                     [showDownload]="downloadCourseEnabled && downloadEnabled"></core-courses-course-list-item> | ||||
|                 <core-courses-course-list-item [course]="course" class="core-recentlyaccessedcourses" layout="summarycard"> | ||||
|                 </core-courses-course-list-item> | ||||
|             </ng-container> | ||||
|             <div class="safe-area-pseudo-padding-end"></div> | ||||
|         </div> | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||||
| import { Component, OnInit, OnDestroy } from '@angular/core'; | ||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { | ||||
| @ -41,17 +41,13 @@ import { CoreSite } from '@classes/site'; | ||||
| }) | ||||
| export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy { | ||||
| 
 | ||||
|     @Input() downloadEnabled = false; | ||||
| 
 | ||||
|     courses: AddonBlockRecentlyAccessedCourse[] = []; | ||||
| 
 | ||||
|     downloadCourseEnabled = false; | ||||
|     scrollElementId!: string; | ||||
| 
 | ||||
|     protected site!: CoreSite; | ||||
|     protected isDestroyed = false; | ||||
|     protected coursesObserver?: CoreEventObserver; | ||||
|     protected updateSiteObserver?: CoreEventObserver; | ||||
|     protected fetchContentDefaultError = 'Error getting recent courses data.'; | ||||
| 
 | ||||
|     constructor() { | ||||
| @ -69,15 +65,6 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom | ||||
| 
 | ||||
|         this.scrollElementId = `addon-block-recentlyaccessedcourses-scroll-${scrollId}`; | ||||
| 
 | ||||
|         // Refresh the enabled flags if enabled.
 | ||||
|         this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
| 
 | ||||
|         // Refresh the enabled flags if site is updated.
 | ||||
|         this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { | ||||
|             this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
| 
 | ||||
|         }, this.site.getId()); | ||||
| 
 | ||||
|         this.coursesObserver = CoreEvents.on( | ||||
|             CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, | ||||
|             (data) => { | ||||
| @ -208,7 +195,6 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom | ||||
|     ngOnDestroy(): void { | ||||
|         this.isDestroyed = true; | ||||
|         this.coursesObserver?.off(); | ||||
|         this.updateSiteObserver?.off(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, Input } from '@angular/core'; | ||||
| import { Component, OnInit } from '@angular/core'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { CoreCourse } from '@features/course/services/course'; | ||||
| import { CoreCourseHelper, CoreCourseSection } from '@features/course/services/course-helper'; | ||||
| @ -29,8 +29,6 @@ import { CoreBlockBaseComponent } from '@features/block/classes/base-block-compo | ||||
| }) | ||||
| export class AddonBlockSiteMainMenuComponent extends CoreBlockBaseComponent implements OnInit { | ||||
| 
 | ||||
|     @Input() downloadEnabled = false; | ||||
| 
 | ||||
|     component = 'AddonBlockSiteMainMenu'; | ||||
|     mainMenuBlock?: CoreCourseSection; | ||||
|     siteHomeId = 1; | ||||
|  | ||||
| @ -16,8 +16,8 @@ | ||||
|         <div (onResize)="scrollControls.updateScrollPosition()" class="flex-row"> | ||||
|             <div class="safe-area-pseudo-padding-start"></div> | ||||
|             <ng-container *ngFor="let course of courses"> | ||||
|                 <core-courses-course-list-item [course]="course" class="core-block_starredcourses" layout="summarycard" | ||||
|                     [showDownload]="downloadCourseEnabled && downloadEnabled"></core-courses-course-list-item> | ||||
|                 <core-courses-course-list-item [course]="course" class="core-block_starredcourses" layout="summarycard"> | ||||
|                 </core-courses-course-list-item> | ||||
|             </ng-container> | ||||
|             <div class="safe-area-pseudo-padding-end"></div> | ||||
|         </div> | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||||
| import { Component, OnInit, OnDestroy } from '@angular/core'; | ||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { CoreCoursesProvider, CoreCoursesMyCoursesUpdatedEventData, CoreCourses } from '@features/courses/services/courses'; | ||||
| @ -36,17 +36,13 @@ import { AddonBlockStarredCourse, AddonBlockStarredCourses } from '../../service | ||||
| }) | ||||
| export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy { | ||||
| 
 | ||||
|     @Input() downloadEnabled = false; | ||||
| 
 | ||||
|     courses: AddonBlockStarredCoursesCourse[] = []; | ||||
| 
 | ||||
|     downloadCourseEnabled = false; | ||||
|     scrollElementId!: string; | ||||
| 
 | ||||
|     protected site: CoreSite; | ||||
|     protected isDestroyed = false; | ||||
|     protected coursesObserver?: CoreEventObserver; | ||||
|     protected updateSiteObserver?: CoreEventObserver; | ||||
|     protected fetchContentDefaultError = 'Error getting starred courses data.'; | ||||
| 
 | ||||
|     constructor() { | ||||
| @ -64,14 +60,6 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im | ||||
| 
 | ||||
|         this.scrollElementId = `addon-block-starredcourses-scroll-${scrollId}`; | ||||
| 
 | ||||
|         // Refresh the enabled flags if enabled.
 | ||||
|         this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
| 
 | ||||
|         // Refresh the enabled flags if site is updated.
 | ||||
|         this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { | ||||
|             this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
|         }, CoreSites.getCurrentSiteId()); | ||||
| 
 | ||||
|         this.coursesObserver = CoreEvents.on( | ||||
|             CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, | ||||
|             (data) => { | ||||
| @ -194,7 +182,6 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im | ||||
|     ngOnDestroy(): void { | ||||
|         this.isDestroyed = true; | ||||
|         this.coursesObserver?.off(); | ||||
|         this.updateSiteObserver?.off(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -2,11 +2,6 @@ | ||||
|     <ion-button *ngIf="searchEnabled" (click)="openSearch()" [attr.aria-label]="'core.courses.searchcourses' | translate"> | ||||
|         <ion-icon name="fas-search" slot="icon-only" aria-hidden="true"></ion-icon> | ||||
|     </ion-button> | ||||
|     <core-context-menu> | ||||
|         <core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="1000" | ||||
|             [content]="'core.settings.showdownloadoptions' | translate" (action)="switchDownload()" iconAction="toggle" | ||||
|             [(toggle)]="downloadEnabled"></core-context-menu-item> | ||||
|     </core-context-menu> | ||||
| </core-navbar-buttons> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!loaded" (ionRefresh)="refreshDashboard($event.target)"> | ||||
| @ -16,8 +11,7 @@ | ||||
|     <core-loading [hideUntil]="loaded"> | ||||
|         <ion-list> | ||||
|             <ng-container *ngFor="let block of blocks"> | ||||
|                 <core-block *ngIf="block.visible" [block]="block" contextLevel="user" [instanceId]="userId" | ||||
|                     [extraData]="{'downloadEnabled': downloadEnabled}"></core-block> | ||||
|                 <core-block *ngIf="block.visible" [block]="block" contextLevel="user" [instanceId]="userId"></core-block> | ||||
|             </ng-container> | ||||
|         </ion-list> | ||||
| 
 | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| import { Component, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core'; | ||||
| import { IonRefresher } from '@ionic/angular'; | ||||
| 
 | ||||
| import { CoreCourses, CoreCoursesProvider } from '../../services/courses'; | ||||
| import { CoreCourses } from '../../services/courses'; | ||||
| import { CoreEventObserver, CoreEvents } from '@singletons/events'; | ||||
| import { CoreSites } from '@services/sites'; | ||||
| import { CoreCoursesDashboard } from '@features/courses/services/dashboard'; | ||||
| @ -39,7 +39,6 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
| 
 | ||||
|     hasSideBlocks = false; | ||||
|     searchEnabled = false; | ||||
|     downloadEnabled = false; | ||||
|     downloadCourseEnabled = false; | ||||
|     downloadCoursesEnabled = false; | ||||
|     userId?: number; | ||||
| @ -47,7 +46,6 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|     loaded = false; | ||||
| 
 | ||||
|     protected updateSiteObserver: CoreEventObserver; | ||||
|     protected downloadEnabledObserver: CoreEventObserver; | ||||
| 
 | ||||
|     constructor() { | ||||
|         // Refresh the enabled flags if site is updated.
 | ||||
| @ -56,12 +54,7 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|             this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
|             this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); | ||||
| 
 | ||||
|             this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled; | ||||
|         }, CoreSites.getCurrentSiteId()); | ||||
| 
 | ||||
|         this.downloadEnabledObserver = CoreEvents.on(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED, (data) => { | ||||
|             this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && data.enabled; | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -72,9 +65,6 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|         this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); | ||||
|         this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); | ||||
| 
 | ||||
|         this.downloadEnabled = | ||||
|             (this.downloadCourseEnabled || this.downloadCoursesEnabled) && CoreCourses.getCourseDownloadOptionsEnabled(); | ||||
| 
 | ||||
|         this.loadContent(); | ||||
|     } | ||||
| 
 | ||||
| @ -153,13 +143,6 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Switch download enabled. | ||||
|      */ | ||||
|     switchDownload(): void { | ||||
|         CoreCourses.setCourseDownloadOptionsEnabled(this.downloadEnabled); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Go to search courses. | ||||
|      */ | ||||
| @ -172,7 +155,6 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|      */ | ||||
|     ngOnDestroy(): void { | ||||
|         this.updateSiteObserver.off(); | ||||
|         this.downloadEnabledObserver.off(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -48,8 +48,7 @@ | ||||
|             </div> | ||||
|         </ion-item> | ||||
|         <ion-list> | ||||
|             <core-block *ngIf="loadedBlock?.visible" [block]="loadedBlock" contextLevel="user" [instanceId]="userId" | ||||
|                 [extraData]="{'downloadEnabled': true}"></core-block> | ||||
|             <core-block *ngIf="loadedBlock?.visible" [block]="loadedBlock" contextLevel="user" [instanceId]="userId"></core-block> | ||||
|         </ion-list> | ||||
| 
 | ||||
|         <core-empty-box *ngIf="!loadedBlock" icon="fas-cubes" [message]="'core.course.nocontentavailable' | translate"> | ||||
|  | ||||
| @ -34,7 +34,6 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges { | ||||
| 
 | ||||
|     @Input() course?: CoreCourseAnyCourseData; // The course to render.
 | ||||
|     @Input() sections?: CoreCourseSection[]; // List of course sections. The status will be calculated in this component.
 | ||||
|     @Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled.
 | ||||
|     @Input() initialSectionId?: number; // The section to load first (by ID).
 | ||||
|     @Input() initialSectionNumber?: number; // The section to load first (by number).
 | ||||
|     @Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
 | ||||
| @ -71,7 +70,6 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges { | ||||
|                 this.method = handler.handlerSchema.method; | ||||
|                 this.args = { | ||||
|                     courseid: this.course.id, | ||||
|                     downloadenabled: this.downloadEnabled, | ||||
|                 }; | ||||
|                 this.initResult = handler.initResult; | ||||
|             } | ||||
| @ -81,7 +79,6 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges { | ||||
|         this.data = { | ||||
|             course: this.course, | ||||
|             sections: this.sections, | ||||
|             downloadEnabled: this.downloadEnabled, | ||||
|             initialSectionId: this.initialSectionId, | ||||
|             initialSectionNumber: this.initialSectionNumber, | ||||
|             moduleId: this.moduleId, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user