MOBILE-2302 courses: Improve course progress treatment
parent
02622db2d0
commit
730631e153
|
@ -45,15 +45,23 @@ export class CoreProgressBarComponent implements OnChanges {
|
|||
|
||||
if (changes.progress) {
|
||||
// Progress has changed.
|
||||
this.width = this.sanitizer.bypassSecurityTrustStyle(this.progress + '%');
|
||||
if (typeof this.progress == 'string') {
|
||||
this.progress = parseInt(this.progress, 10);
|
||||
}
|
||||
|
||||
if (this.progress < 0 || isNaN(this.progress)) {
|
||||
this.progress = -1;
|
||||
} else if (!this.textSupplied) {
|
||||
this.text = String(this.progress);
|
||||
}
|
||||
|
||||
if (this.progress != -1) {
|
||||
// Remove decimals.
|
||||
this.progress = Math.floor(this.progress);
|
||||
|
||||
if (!this.textSupplied) {
|
||||
this.text = String(this.progress);
|
||||
}
|
||||
|
||||
this.width = this.sanitizer.bypassSecurityTrustStyle(this.progress + '%');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<ion-card>
|
||||
<a ion-item text-wrap class="item-course" (click)="openCourse(course)" [title]="course.fullname">
|
||||
<h2><core-format-text [text]="course.fullname"></core-format-text></h2>
|
||||
<core-progress-bar *ngIf="course.progress !== false" [progress]="course.progress"></core-progress-bar>
|
||||
<core-progress-bar *ngIf="course.progress != null && course.progress >= 0" [progress]="course.progress"></core-progress-bar>
|
||||
<!-- @todo: Download button. -->
|
||||
<!-- <i *ngIf="actionsLoaded" class="icon ion-android-more-vertical mm-animate-show-hide" ng-click="showCourseActions($event)"></i>
|
||||
<ion-spinner *ngIf="!actionsLoaded" class="mm-animate-show-hide"></ion-spinner> -->
|
||||
|
|
|
@ -78,7 +78,6 @@ export class CoreCoursesMyCoursesPage implements OnDestroy {
|
|||
|
||||
return this.coursesProvider.getCoursesOptions(courseIds).then((options) => {
|
||||
courses.forEach((course) => {
|
||||
course.progress = isNaN(parseInt(course.progress, 10)) ? false : parseInt(course.progress, 10);
|
||||
course.navOptions = options.navOptions[course.id];
|
||||
course.admOptions = options.admOptions[course.id];
|
||||
});
|
||||
|
|
|
@ -166,8 +166,6 @@ export class CoreCoursesMyOverviewPage {
|
|||
// Load course options of the course.
|
||||
return this.coursesProvider.getCoursesOptions(courseIds).then((options) => {
|
||||
courses.forEach((course) => {
|
||||
course.progress = isNaN(parseInt(course.progress, 10)) ? false : parseInt(course.progress, 10);
|
||||
|
||||
course.navOptions = options.navOptions[course.id];
|
||||
course.admOptions = options.admOptions[course.id];
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue