MOBILE-3686 dashboard: Fix dashboard download options

main
Pau Ferrer Ocaña 2021-10-14 10:36:20 +02:00
parent 264309593f
commit 577aa3168f
3 changed files with 4 additions and 12 deletions

View File

@ -6,7 +6,7 @@
<core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="1000" <core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="1000"
[content]="'core.settings.showdownloadoptions' | translate" (action)="switchDownload(!downloadEnabled)" [content]="'core.settings.showdownloadoptions' | translate" (action)="switchDownload(!downloadEnabled)"
iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item> iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item>
<core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="500" <core-context-menu-item [priority]="500"
[content]="'addon.storagemanager.managestorage' | translate" [content]="'addon.storagemanager.managestorage' | translate"
(action)="manageCoursesStorage()" iconAction="fas-archive"></core-context-menu-item> (action)="manageCoursesStorage()" iconAction="fas-archive"></core-context-menu-item>
</core-context-menu> </core-context-menu>

View File

@ -3,10 +3,10 @@
<ion-icon name="fas-search" slot="icon-only" aria-hidden="true"></ion-icon> <ion-icon name="fas-search" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button> </ion-button>
<core-context-menu> <core-context-menu>
<core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="1000" <core-context-menu-item [priority]="1000"
[content]="'core.settings.showdownloadoptions' | translate" (action)="switchDownload(!downloadEnabled)" [content]="'core.settings.showdownloadoptions' | translate" (action)="switchDownload(!downloadEnabled)"
iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item> iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item>
<core-context-menu-item *ngIf="(downloadCourseEnabled || downloadCoursesEnabled)" [priority]="500" <core-context-menu-item [priority]="500"
[content]="'addon.storagemanager.managestorage' | translate" [content]="'addon.storagemanager.managestorage' | translate"
(action)="manageCoursesStorage()" iconAction="fas-archive"></core-context-menu-item> (action)="manageCoursesStorage()" iconAction="fas-archive"></core-context-menu-item>
</core-context-menu> </core-context-menu>

View File

@ -51,8 +51,6 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
currentSite!: CoreSite; currentSite!: CoreSite;
searchEnabled = false; searchEnabled = false;
downloadEnabled = false; downloadEnabled = false;
downloadCourseEnabled = false;
downloadCoursesEnabled = false;
newsForumModule?: NewsForum; newsForumModule?: NewsForum;
protected updateSiteObserver?: CoreEventObserver; protected updateSiteObserver?: CoreEventObserver;
@ -62,16 +60,10 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
*/ */
ngOnInit(): void { ngOnInit(): void {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite(); this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
// Refresh the enabled flags if site is updated. // Refresh the enabled flags if site is updated.
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite(); this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.switchDownload(this.downloadEnabled && this.downloadCourseEnabled && this.downloadCoursesEnabled);
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());
this.currentSite = CoreSites.getRequiredCurrentSite(); this.currentSite = CoreSites.getRequiredCurrentSite();
@ -194,7 +186,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
* @param enable If enable or disable. * @param enable If enable or disable.
*/ */
protected switchDownload(enable: boolean): void { protected switchDownload(enable: boolean): void {
this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && enable; this.downloadEnabled = enable;
CoreEvents.trigger(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED, { enabled: this.downloadEnabled }); CoreEvents.trigger(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED, { enabled: this.downloadEnabled });
} }