From dc08698aac57f2b00170d44a9e8a0ecd46786599 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?=
Date: Thu, 25 Nov 2021 11:52:28 +0100
Subject: [PATCH] MOBILE-3806 course: Fix and improve course list item
---
.../core-courses-course-list-item.html | 72 +++++++------------
.../course-list-item/course-list-item.ts | 10 +--
.../course-progress/course-progress.ts | 6 +-
3 files changed, 36 insertions(+), 52 deletions(-)
diff --git a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html
index 73b78fa5a..91e596ed5 100644
--- a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html
+++ b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html
@@ -10,27 +10,7 @@
-
-
-
-
- |
-
-
-
-
-
-
-
-
- {{ 'core.courses.aria:favourite' | translate }}
- {{ 'core.courses.aria:coursename' | translate }}
-
-
-
+
@@ -47,11 +27,10 @@
-
+ class="core-course-list-card" [class.item-dimmed]="course.hidden" [attr.aria-label]="course.displayname || course.fullname">
![]()
@@ -62,28 +41,7 @@
-
- {{ 'core.courses.aria:coursecategory' | translate }}
-
-
-
- |
-
-
-
-
-
-
-
-
- {{ 'core.courses.aria:favourite' | translate }}
- {{ 'core.courses.aria:coursename' | translate }}
-
-
-
+
@@ -122,3 +80,27 @@
+
+
+
+
+ {{ 'core.courses.aria:coursecategory' | translate }}
+
+
+ |
+
+
+
+
+
+
+
+
+ {{ 'core.courses.aria:favourite' | translate }}
+ {{ 'core.courses.aria:coursename' | translate }}
+
+
+
+
diff --git a/src/core/features/courses/components/course-list-item/course-list-item.ts b/src/core/features/courses/components/course-list-item/course-list-item.ts
index 98e98ba99..70304420b 100644
--- a/src/core/features/courses/components/course-list-item/course-list-item.ts
+++ b/src/core/features/courses/components/course-list-item/course-list-item.ts
@@ -250,13 +250,13 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
}
/**
- * Delete the course.
+ * Delete course stored data.
*/
- async deleteCourse(): Promise {
+ async deleteCourseStoredData(): Promise {
try {
await CoreDomUtils.showDeleteConfirm('core.course.confirmdeletestoreddata');
} catch (error) {
- if (CoreDomUtils.isCanceledError(error)) {
+ if (!CoreDomUtils.isCanceledError(error)) {
throw error;
}
@@ -299,8 +299,8 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
}
break;
case 'delete':
- if (this.courseStatus == 'downloaded' || this.courseStatus == 'outdated') {
- this.deleteCourse();
+ if (this.courseStatus == CoreConstants.DOWNLOADED || this.courseStatus == CoreConstants.OUTDATED) {
+ this.deleteCourseStoredData();
}
break;
case 'hide':
diff --git a/src/core/features/courses/components/course-progress/course-progress.ts b/src/core/features/courses/components/course-progress/course-progress.ts
index 626c6c9a8..7b1e37c7b 100644
--- a/src/core/features/courses/components/course-progress/course-progress.ts
+++ b/src/core/features/courses/components/course-progress/course-progress.ts
@@ -35,6 +35,8 @@ import { CoreUser } from '@features/user/services/user';
*
*
*
+ *
+ * @deprecated since 4.0 Use core-courses-course-list-item instead.
*/
@Component({
selector: 'core-courses-course-progress',
@@ -175,7 +177,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy, On
try {
await CoreDomUtils.showDeleteConfirm('core.course.confirmdeletestoreddata');
} catch (error) {
- if (CoreDomUtils.isCanceledError(error)) {
+ if (!CoreDomUtils.isCanceledError(error)) {
throw error;
}
@@ -233,7 +235,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy, On
}
break;
case 'delete':
- if (this.courseStatus == 'downloaded' || this.courseStatus == 'outdated') {
+ if (this.courseStatus == CoreConstants.DOWNLOADED || this.courseStatus == CoreConstants.OUTDATED) {
this.deleteCourse();
}
break;