MOBILE-3970 course: Delete download course from Course summary
parent
19b3a394d2
commit
449727d2c2
|
@ -124,19 +124,6 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ion-button class="ion-margin" *ngIf="canAccessCourse && downloadCourseEnabled" (click)="prefetchCourse()" expand="block"
|
|
||||||
[attr.aria-label]="prefetchCourseData.statusTranslatable | translate">
|
|
||||||
<ion-icon *ngIf="(prefetchCourseData.status != statusDownloaded) && !prefetchCourseData.loading" [name]="prefetchCourseData.icon"
|
|
||||||
slot="start" aria-hidden="true">
|
|
||||||
</ion-icon>
|
|
||||||
<ion-icon *ngIf="(prefetchCourseData.status == statusDownloaded) && !prefetchCourseData.loading" slot="start"
|
|
||||||
[name]="prefetchCourseData.icon" color="success" aria-hidden="true" role="status">
|
|
||||||
</ion-icon>
|
|
||||||
<ion-spinner *ngIf="prefetchCourseData.loading" slot="start" [attr.aria-label]="'core.loading' | translate"></ion-spinner>
|
|
||||||
<ion-label *ngIf="prefetchCourseData.status != statusDownloaded">{{ 'core.course.downloadcourse' | translate }}</ion-label>
|
|
||||||
<ion-label *ngIf="prefetchCourseData.status == statusDownloaded">{{ 'core.course.refreshcourse' | translate }}</ion-label>
|
|
||||||
</ion-button>
|
|
||||||
|
|
||||||
<ion-button class="ion-margin" (click)="openCourse()" *ngIf="!avoidOpenCourse && canAccessCourse" expand="block">
|
<ion-button class="ion-margin" (click)="openCourse()" *ngIf="!avoidOpenCourse && canAccessCourse" expand="block">
|
||||||
<ion-icon name="fas-briefcase" slot="start" aria-hidden="true"></ion-icon>
|
<ion-icon name="fas-briefcase" slot="start" aria-hidden="true"></ion-icon>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
|
|
|
@ -27,10 +27,8 @@ import {
|
||||||
CoreEnrolledCourseData,
|
CoreEnrolledCourseData,
|
||||||
} from '@features/courses/services/courses';
|
} from '@features/courses/services/courses';
|
||||||
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
|
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
|
||||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
|
||||||
import { ModalController, NgZone, Platform, Translate } from '@singletons';
|
import { ModalController, NgZone, Platform, Translate } from '@singletons';
|
||||||
import { CoreConstants } from '@/core/constants';
|
|
||||||
import { CoreCoursesSelfEnrolPasswordComponent } from '../../../courses/components/self-enrol-password/self-enrol-password';
|
import { CoreCoursesSelfEnrolPasswordComponent } from '../../../courses/components/self-enrol-password/self-enrol-password';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -56,16 +54,7 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||||
paypalEnabled = false;
|
paypalEnabled = false;
|
||||||
dataLoaded = false;
|
dataLoaded = false;
|
||||||
avoidOpenCourse = false;
|
avoidOpenCourse = false;
|
||||||
prefetchCourseData: CorePrefetchStatusInfo = {
|
|
||||||
icon: '',
|
|
||||||
statusTranslatable: 'core.loading',
|
|
||||||
status: '',
|
|
||||||
loading: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
statusDownloaded = CoreConstants.DOWNLOADED;
|
|
||||||
|
|
||||||
downloadCourseEnabled: boolean;
|
|
||||||
courseUrl = '';
|
courseUrl = '';
|
||||||
courseImageUrl?: string;
|
courseImageUrl?: string;
|
||||||
progress?: number;
|
progress?: number;
|
||||||
|
@ -82,17 +71,6 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||||
protected waitingForBrowserEnrol = false;
|
protected waitingForBrowserEnrol = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.downloadCourseEnabled = !CoreCourses.isDownloadCourseDisabledInSite();
|
|
||||||
|
|
||||||
if (this.downloadCourseEnabled) {
|
|
||||||
// Listen for status change in course.
|
|
||||||
this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data) => {
|
|
||||||
if (data.courseId == this.courseId || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
|
||||||
this.updateCourseStatus(data.status);
|
|
||||||
}
|
|
||||||
}, CoreSites.getCurrentSiteId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh the view when the app is resumed.
|
// Refresh the view when the app is resumed.
|
||||||
this.appResumeSubscription = Platform.resume.subscribe(() => {
|
this.appResumeSubscription = Platform.resume.subscribe(() => {
|
||||||
if (!this.waitingForBrowserEnrol || !this.dataLoaded) {
|
if (!this.waitingForBrowserEnrol || !this.dataLoaded) {
|
||||||
|
@ -134,31 +112,7 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||||
this.enrolUrl = CoreTextUtils.concatenatePaths(currentSiteUrl, 'enrol/index.php?id=' + this.courseId);
|
this.enrolUrl = CoreTextUtils.concatenatePaths(currentSiteUrl, 'enrol/index.php?id=' + this.courseId);
|
||||||
this.courseUrl = CoreTextUtils.concatenatePaths(currentSiteUrl, 'course/view.php?id=' + this.courseId);
|
this.courseUrl = CoreTextUtils.concatenatePaths(currentSiteUrl, 'course/view.php?id=' + this.courseId);
|
||||||
|
|
||||||
try {
|
await this.getCourse();
|
||||||
await this.getCourse();
|
|
||||||
} finally {
|
|
||||||
if (this.downloadCourseEnabled) {
|
|
||||||
|
|
||||||
// Determine course prefetch icon.
|
|
||||||
this.prefetchCourseData = await CoreCourseHelper.getCourseStatusIconAndTitle(this.courseId);
|
|
||||||
|
|
||||||
if (this.prefetchCourseData.loading) {
|
|
||||||
// Course is being downloaded. Get the download promise.
|
|
||||||
const promise = CoreCourseHelper.getCourseDownloadPromise(this.courseId);
|
|
||||||
if (promise) {
|
|
||||||
// There is a download promise. If it fails, show an error.
|
|
||||||
promise.catch((error) => {
|
|
||||||
if (!this.pageDestroyed) {
|
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// No download, this probably means that the app was closed while downloading. Set previous status.
|
|
||||||
CoreCourse.setCoursePreviousStatus(this.courseId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,20 +364,6 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the course status icon and title.
|
|
||||||
*
|
|
||||||
* @param status Status to show.
|
|
||||||
*/
|
|
||||||
protected updateCourseStatus(status: string): void {
|
|
||||||
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
|
||||||
|
|
||||||
this.prefetchCourseData.status = statusData.status;
|
|
||||||
this.prefetchCourseData.icon = statusData.icon;
|
|
||||||
this.prefetchCourseData.statusTranslatable = statusData.statusTranslatable;
|
|
||||||
this.prefetchCourseData.loading = statusData.loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the user to be enrolled in the course.
|
* Wait for the user to be enrolled in the course.
|
||||||
*
|
*
|
||||||
|
@ -466,21 +406,6 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||||
ModalController.dismiss();
|
ModalController.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prefetch the course.
|
|
||||||
*/
|
|
||||||
async prefetchCourse(): Promise<void> {
|
|
||||||
try {
|
|
||||||
await CoreCourseHelper.confirmAndPrefetchCourse(this.prefetchCourseData, this.course as CoreEnrolledCourseData, {
|
|
||||||
isGuest: this.useGuestAccess,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
if (!this.pageDestroyed) {
|
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue