MOBILE-3686 courses: Do not check my courses disabled on list

main
Pau Ferrer Ocaña 2021-10-14 13:07:29 +02:00
parent 27ceb96127
commit aef7a64db7
8 changed files with 14 additions and 31 deletions

View File

@ -12,7 +12,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)="toggleDownload(!downloadEnabled)" [content]="'core.settings.showdownloadoptions' | translate" (action)="toggleDownload(!downloadEnabled)"
iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item> iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item>
<core-context-menu-item *ngIf="myCoursesEnabled" [priority]="900" <core-context-menu-item [priority]="900"
[content]="'core.courses.showonlyenrolled' | translate" (action)="toggleEnrolled(!showOnlyEnrolled)" [content]="'core.courses.showonlyenrolled' | translate" (action)="toggleEnrolled(!showOnlyEnrolled)"
iconAction="toggle" [toggle]="showOnlyEnrolled"></core-context-menu-item> iconAction="toggle" [toggle]="showOnlyEnrolled"></core-context-menu-item>
</core-context-menu> </core-context-menu>

View File

@ -36,7 +36,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy {
categories: CoreCategoryData[] = []; categories: CoreCategoryData[] = [];
courses: CoreCourseListItem[] = []; courses: CoreCourseListItem[] = [];
categoriesLoaded = false; categoriesLoaded = false;
myCoursesEnabled = true;
showOnlyEnrolled = false; showOnlyEnrolled = false;
@ -72,7 +71,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy {
this.siteUpdatedObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { this.siteUpdatedObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite();
this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled; this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled;
}, this.currentSiteId); }, this.currentSiteId);
@ -91,7 +89,6 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy {
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite();
this.downloadEnabled = this.downloadEnabled =
(this.downloadCourseEnabled || this.downloadCoursesEnabled) && CoreCourses.getCourseDownloadOptionsEnabled(); (this.downloadCourseEnabled || this.downloadCoursesEnabled) && CoreCourses.getCourseDownloadOptionsEnabled();

View File

@ -148,11 +148,11 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy {
} }
/** /**
* Convenience function to switch download enabled. * Switch download enabled.
* *
* @param enable If enable or disable. * @param enable If enable or disable.
*/ */
protected switchDownload(enable: boolean): void { switchDownload(enable: boolean): void {
this.downloadEnabled = this.downloadEnabled =
CoreCourses.setCourseDownloadOptionsEnabled((this.downloadCourseEnabled || this.downloadCoursesEnabled) && enable); CoreCourses.setCourseDownloadOptionsEnabled((this.downloadCourseEnabled || this.downloadCoursesEnabled) && enable);
} }

View File

@ -11,7 +11,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)="toggleDownload(!downloadEnabled)" [content]="'core.settings.showdownloadoptions' | translate" (action)="toggleDownload(!downloadEnabled)"
iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item> iconAction="toggle" [toggle]="downloadEnabled"></core-context-menu-item>
<core-context-menu-item *ngIf="myCoursesEnabled" [priority]="900" <core-context-menu-item [priority]="900"
[content]="'core.courses.showonlyenrolled' | translate" (action)="toggleEnrolled(!showOnlyEnrolled)" [content]="'core.courses.showonlyenrolled' | translate" (action)="toggleEnrolled(!showOnlyEnrolled)"
iconAction="toggle" [toggle]="showOnlyEnrolled"></core-context-menu-item> iconAction="toggle" [toggle]="showOnlyEnrolled"></core-context-menu-item>
</core-context-menu> </core-context-menu>

View File

@ -35,7 +35,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
downloadAllCoursesEnabled = false; downloadAllCoursesEnabled = false;
searchEnabled = false; searchEnabled = false;
myCoursesEnabled = true;
searchMode = false; searchMode = false;
searchCanLoadMore = false; searchCanLoadMore = false;
searchLoadMoreError = false; searchLoadMoreError = false;
@ -84,7 +83,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite(); this.searchEnabled = !CoreCourses.isSearchCoursesDisabledInSite();
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite(); this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite();
this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled; this.downloadEnabled = (this.downloadCourseEnabled || this.downloadCoursesEnabled) && this.downloadEnabled;
if (!this.searchEnabled) { if (!this.searchEnabled) {
@ -111,12 +109,6 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
this.mode = CoreNavigator.getRouteParam<CoreCoursesListMode>('mode') || this.mode; this.mode = CoreNavigator.getRouteParam<CoreCoursesListMode>('mode') || this.mode;
this.myCoursesEnabled = !CoreCourses.isMyCoursesDisabledInSite();
if (this.mode == 'my' && !this.myCoursesEnabled) {
this.mode = 'all';
this.showOnlyEnrolled = false;
}
if (this.mode == 'search') { if (this.mode == 'search') {
this.searchMode = true; this.searchMode = true;
} }
@ -140,8 +132,10 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
*/ */
protected async fetchCourses(): Promise<void> { protected async fetchCourses(): Promise<void> {
try { try {
if (this.searchMode && this.searchText) { if (this.searchMode) {
await this.search(this.searchText); if (this.searchText) {
await this.search(this.searchText);
}
} else if (this.showOnlyEnrolled) { } else if (this.showOnlyEnrolled) {
await this.loadMyCourses(); await this.loadMyCourses();
} else { } else {

View File

@ -107,7 +107,7 @@ export class CoreCoursesDashboardProvider {
} }
/** /**
* Check if Site Home is disabled in a certain site. * Check if Dashboard is disabled in a certain site.
* *
* @param site Site. If not defined, use current site. * @param site Site. If not defined, use current site.
* @return Whether it's disabled. * @return Whether it's disabled.

View File

@ -194,11 +194,11 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
} }
/** /**
* Convenience function to switch download enabled. * Switch download enabled.
* *
* @param enable If enable or disable. * @param enable If enable or disable.
*/ */
protected switchDownload(enable: boolean): void { switchDownload(enable: boolean): void {
this.downloadEnabled = this.downloadEnabled =
CoreCourses.setCourseDownloadOptionsEnabled(enable); CoreCourses.setCourseDownloadOptionsEnabled(enable);
} }

View File

@ -169,20 +169,12 @@ export class CoreSiteHomeProvider {
// Get number of news items to show. // Get number of news items to show.
add = !!CoreSites.getCurrentSite()?.getStoredConfig('newsitems'); add = !!CoreSites.getCurrentSite()?.getStoredConfig('newsitems');
break; break;
case FrontPageItemNames['LIST_OF_CATEGORIES']:
case FrontPageItemNames['COMBO_LIST']: case FrontPageItemNames['COMBO_LIST']:
itemNumber = FrontPageItemNames['LIST_OF_CATEGORIES']; // Do not break here.
case FrontPageItemNames['LIST_OF_CATEGORIES']:
case FrontPageItemNames['LIST_OF_COURSE']: case FrontPageItemNames['LIST_OF_COURSE']:
add = true;
if (itemNumber == FrontPageItemNames['COMBO_LIST']) {
itemNumber = FrontPageItemNames['LIST_OF_CATEGORIES'];
}
break;
case FrontPageItemNames['ENROLLED_COURSES']: case FrontPageItemNames['ENROLLED_COURSES']:
if (!CoreCourses.isMyCoursesDisabledInSite()) { add = true;
const courses = await CoreCourses.getUserCourses();
add = courses.length > 0;
}
break; break;
case FrontPageItemNames['COURSE_SEARCH_BOX']: case FrontPageItemNames['COURSE_SEARCH_BOX']:
add = !CoreCourses.isSearchCoursesDisabledInSite(); add = !CoreCourses.isSearchCoursesDisabledInSite();