diff --git a/src/core/courses/components/course-progress/course-progress.scss b/src/core/courses/components/course-progress/course-progress.scss
index e99d46143..ca366793b 100644
--- a/src/core/courses/components/course-progress/course-progress.scss
+++ b/src/core/courses/components/course-progress/course-progress.scss
@@ -56,6 +56,10 @@ ion-app.app-root core-courses-course-progress {
margins: 6px 0;
flex-grow: 1;
}
+
+ &.core-course-more-than-title {
+ padding-bottom: 0;
+ }
}
.label {
@include margin(0, 0, 0, null);
diff --git a/src/core/courses/components/course-progress/course-progress.ts b/src/core/courses/components/course-progress/course-progress.ts
index 96f9b60b5..6e4ac089d 100644
--- a/src/core/courses/components/course-progress/course-progress.ts
+++ b/src/core/courses/components/course-progress/course-progress.ts
@@ -13,14 +13,16 @@
// limitations under the License.
import { Component, Input, OnInit, OnDestroy, Optional } from '@angular/core';
-import { NavController } from 'ionic-angular';
+import { NavController, PopoverController } from 'ionic-angular';
import { CoreEventsProvider } from '@providers/events';
import { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
+import { CoreUserProvider } from '@core/user/providers/user';
import { CoreCoursesProvider } from '@core/courses/providers/courses';
import { CoreCourseFormatDelegate } from '@core/course/providers/format-delegate';
import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
+import { CoreCoursesCourseOptionsMenuComponent } from '../course-options-menu/course-options-menu';
/**
* This component is meant to display a course for a list of courses with progress.
@@ -42,7 +44,9 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
prefetchCourseIcon: 'spinner',
title: 'core.course.downloadcourse'
};
+ showSpinner = false;
downloadCourseEnabled: boolean;
+ courseOptionMenuEnabled: boolean;
protected isDestroyed = false;
protected courseStatusObserver;
@@ -51,7 +55,8 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
constructor(@Optional() private navCtrl: NavController, private courseHelper: CoreCourseHelperProvider,
private courseFormatDelegate: CoreCourseFormatDelegate, private domUtils: CoreDomUtilsProvider,
private courseProvider: CoreCourseProvider, private eventsProvider: CoreEventsProvider,
- private sitesProvider: CoreSitesProvider, private coursesProvider: CoreCoursesProvider) { }
+ private sitesProvider: CoreSitesProvider, private coursesProvider: CoreCoursesProvider,
+ private popoverCtrl: PopoverController, private userProvider: CoreUserProvider) { }
/**
* Component being initialized.
@@ -63,6 +68,8 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
this.initPrefetchCourse();
}
+ this.courseOptionMenuEnabled = typeof this.course.isfavourite != 'undefined';
+
// Refresh the enabled flag if site is updated.
this.siteUpdatedObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => {
const wasEnabled = this.downloadCourseEnabled;
@@ -153,6 +160,58 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
this.prefetchCourseData.title = statusData.title;
}
+ /**
+ * Show the context menu.
+ *
+ * @param {Event} e Click Event.
+ */
+ showCourseOptionsMenu(e: Event): void {
+ e.preventDefault();
+ e.stopPropagation();
+
+ const popover = this.popoverCtrl.create(CoreCoursesCourseOptionsMenuComponent, {
+ course: this.course,
+ prefetch: this.prefetchCourseData
+ });
+ popover.onDidDismiss((action) => {
+ if (action) {
+ switch (action) {
+ case 'download':
+ this.prefetchCourse(e);
+ break;
+ case 'hide':
+ this.setCourseHidden(true);
+ break;
+ case 'show':
+ this.setCourseHidden(false);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ popover.present({
+ ev: e
+ });
+ }
+
+ /**
+ * Hide/Unhide the course from the course list.
+ *
+ * @param {boolean} hide True to hide and false to show.
+ */
+ protected setCourseHidden(hide: boolean): void {
+ this.showSpinner = true;
+
+ this.userProvider.updateUserPreference('block_myoverview_hidden_course_' + this.course.id, hide ? 1 : false).then(() => {
+ this.course.hidden = hide;
+ this.eventsProvider.trigger(
+ CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {course: this.course}, this.sitesProvider.getCurrentSiteId());
+ }).finally(() => {
+ this.showSpinner = false;
+ });
+ }
+
/**
* Component destroyed.
*/
diff --git a/src/core/courses/lang/en.json b/src/core/courses/lang/en.json
index f961a47ef..818098e23 100644
--- a/src/core/courses/lang/en.json
+++ b/src/core/courses/lang/en.json
@@ -14,6 +14,7 @@
"errorselfenrol": "An error occurred while self enrolling.",
"filtermycourses": "Filter my courses",
"frontpage": "Front page",
+ "hidecourse": "Hide from view",
"mycourses": "My courses",
"nocourses": "No course information to show.",
"nocoursesyet": "No courses in this category",
@@ -28,5 +29,6 @@
"searchcoursesadvice": "You can use the search courses button to find courses to access as a guest or enrol yourself in courses that allow it.",
"selfenrolment": "Self enrolment",
"sendpaymentbutton": "Send payment via PayPal",
+ "show": "Show this course",
"totalcoursesearchresults": "Total courses: {{$a}}"
}
\ No newline at end of file
diff --git a/src/core/courses/pages/course-preview/course-preview.ts b/src/core/courses/pages/course-preview/course-preview.ts
index ce2b0d7cd..51d2253e4 100644
--- a/src/core/courses/pages/course-preview/course-preview.ts
+++ b/src/core/courses/pages/course-preview/course-preview.ts
@@ -353,7 +353,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
this.refreshData().finally(() => {
// My courses have been updated, trigger event.
this.eventsProvider.trigger(
- CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {}, this.sitesProvider.getCurrentSiteId());
+ CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {course: this.course}, this.sitesProvider.getCurrentSiteId());
});
});
}).catch((error) => {