; // Will emit an event when the item clicked.
+
+ statusDownloaded = CoreConstants.DOWNLOADED;
+ statusNotDownloaded = CoreConstants.NOT_DOWNLOADED;
+ statusOutdated = CoreConstants.OUTDATED;
+ statusDownloading = CoreConstants.DOWNLOADING;
+
+ constructor() {
+ this.action = new EventEmitter();
+ }
+
+ /**
+ * Download clicked.
+ *
+ * @param {Event} e Click event.
+ * @param {boolean} refresh Whether it's refreshing.
+ */
+ download(e: Event, refresh: boolean): void {
+ e.preventDefault();
+ e.stopPropagation();
+ this.action.emit(refresh);
+ }
+}
diff --git a/src/core/course/components/format/core-course-format.html b/src/core/course/components/format/core-course-format.html
index 2600ed8fc..9ba99a96c 100644
--- a/src/core/course/components/format/core-course-format.html
+++ b/src/core/course/components/format/core-course-format.html
@@ -90,17 +90,9 @@
-
-
-
-
0 && section.count < section.total">{{section.count}} / {{section.total}}
-
-
+
+
diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts
index 8c5bdbffe..1c87d2aed 100644
--- a/src/core/course/components/format/format.ts
+++ b/src/core/course/components/format/format.ts
@@ -119,7 +119,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
this.courseHelper.calculateSectionStatus(section, this.course.id, false).then(() => {
if (section.isDownloading && !prefetchDelegate.isBeingDownloaded(downloadId)) {
// All the modules are now downloading, set a download all promise.
- this.prefetch(section, false);
+ this.prefetch(section);
}
});
}
@@ -339,13 +339,10 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
/**
* Confirm and prefetch a section. If the section is "all sections", prefetch all the sections.
*
- * @param {Event} e Click event.
* @param {any} section Section to download.
+ * @param {boolean} refresh Refresh clicked (not used).
*/
- prefetch(e: Event, section: any): void {
- e.preventDefault();
- e.stopPropagation();
-
+ prefetch(section: any, refresh: boolean = false): void {
section.isCalculating = true;
this.courseHelper.confirmDownloadSizeSection(this.course.id, section, this.sections).then(() => {
this.prefetchSection(section, true);
diff --git a/src/core/course/components/module-completion/module-completion.scss b/src/core/course/components/module-completion/module-completion.scss
index 95674dc1c..23a677924 100644
--- a/src/core/course/components/module-completion/module-completion.scss
+++ b/src/core/course/components/module-completion/module-completion.scss
@@ -1,4 +1,6 @@
ion-app.app-root core-course-module-completion a {
+ display: block;
+
img {
padding: 5px;
width: 30px;
diff --git a/src/core/course/components/module/core-course-module.html b/src/core/course/components/module/core-course-module.html
index af880f447..6958c4dca 100644
--- a/src/core/course/components/module/core-course-module.html
+++ b/src/core/course/components/module/core-course-module.html
@@ -10,23 +10,12 @@
-
-
-
-
-
+
-
-
-
diff --git a/src/core/course/components/module/module.scss b/src/core/course/components/module/module.scss
index 2541dd63a..2efad78fd 100644
--- a/src/core/course/components/module/module.scss
+++ b/src/core/course/components/module/module.scss
@@ -36,6 +36,8 @@ ion-app.app-root core-course-module {
flex-flow: row;
align-items: center;
z-index: 1;
+ justify-content: space-around;
+ align-content: center;
}
.core-module-buttons core-course-module-completion,
@@ -44,9 +46,8 @@ ion-app.app-root core-course-module {
pointer-events: auto;
}
- .core-module-buttons-more .spinner {
- @include position(null, 13px, null, null);
- position: absolute;
+ .core-module-buttons core-course-module-completion {
+ text-align: center;
}
}
diff --git a/src/core/course/components/module/module.ts b/src/core/course/components/module/module.ts
index ed1c7bbf4..b4d8cba41 100644
--- a/src/core/course/components/module/module.ts
+++ b/src/core/course/components/module/module.ts
@@ -21,7 +21,6 @@ import { CoreCourseHelperProvider } from '../../providers/helper';
import { CoreCourseProvider } from '../../providers/course';
import { CoreCourseModuleHandlerButton } from '../../providers/module-delegate';
import { CoreCourseModulePrefetchDelegate, CoreCourseModulePrefetchHandler } from '../../providers/module-prefetch-delegate';
-import { CoreConstants } from '../../../constants';
/**
* Component to display a module entry in a list of modules.
@@ -52,9 +51,9 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
}
@Output() completionChanged?: EventEmitter; // Will emit an event when the module completion changes.
- showDownload: boolean; // Whether to display the download button.
- showRefresh: boolean; // Whether to display the refresh button.
- spinner: boolean; // Whether to display a spinner.
+ downloadStatus: string;
+ canCheckUpdates: boolean;
+ spinner: boolean; // Whether to display a loading spinner.
downloadEnabled: boolean; // Whether the download of sections and modules is enabled.
protected prefetchHandler: CoreCourseModulePrefetchHandler;
@@ -81,6 +80,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
if (this.module.handlerData.showDownloadButton) {
// Listen for changes on this module status, even if download isn't enabled.
this.prefetchHandler = this.prefetchDelegate.getPrefetchHandlerFor(this.module);
+ this.canCheckUpdates = this.prefetchDelegate.canCheckUpdates();
this.statusObserver = this.eventsProvider.on(CoreEventsProvider.PACKAGE_STATUS_CHANGED, (data) => {
if (data.componentId === this.module.id && this.prefetchHandler &&
@@ -135,13 +135,9 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
/**
* Download the module.
*
- * @param {Event} event Click event.
* @param {boolean} refresh Whether it's refreshing.
*/
- download(event: Event, refresh: boolean): void {
- event.preventDefault();
- event.stopPropagation();
-
+ download(refresh: boolean): void {
if (!this.prefetchHandler) {
return;
}
@@ -168,10 +164,8 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
*/
protected showStatus(status: string): void {
if (status) {
- this.spinner = status === CoreConstants.DOWNLOADING;
- this.showDownload = status === CoreConstants.NOT_DOWNLOADED;
- this.showRefresh = status === CoreConstants.OUTDATED ||
- (!this.prefetchDelegate.canCheckUpdates() && status === CoreConstants.DOWNLOADED);
+ this.spinner = false;
+ this.downloadStatus = status;
if (this.module.handlerData.updateStatus) {
this.module.handlerData.updateStatus(status);
diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts
index 90df6282a..d1eb53fe5 100644
--- a/src/core/course/providers/helper.ts
+++ b/src/core/course/providers/helper.ts
@@ -197,11 +197,9 @@ export class CoreCourseHelperProvider {
result.status = CoreConstants.DOWNLOADING;
}
+ section.downloadStatus = result.status;
+ section.canCheckUpdates = this.prefetchDelegate.canCheckUpdates();
// Set this section data.
- section.showDownload = result.status === CoreConstants.NOT_DOWNLOADED;
- section.showRefresh = result.status === CoreConstants.OUTDATED ||
- (!this.prefetchDelegate.canCheckUpdates() && result.status === CoreConstants.DOWNLOADED);
-
if (result.status !== CoreConstants.DOWNLOADING || !this.prefetchDelegate.isBeingDownloaded(section.id)) {
section.isDownloading = false;
section.total = 0;
@@ -250,9 +248,8 @@ export class CoreCourseHelperProvider {
return Promise.all(promises).then(() => {
if (allSectionsSection) {
// Set "All sections" data.
- allSectionsSection.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED;
- allSectionsSection.showRefresh = allSectionsStatus === CoreConstants.OUTDATED ||
- (!this.prefetchDelegate.canCheckUpdates() && allSectionsStatus === CoreConstants.DOWNLOADED);
+ allSectionsSection.downloadStatus = allSectionsStatus;
+ allSectionsSection.canCheckUpdates = this.prefetchDelegate.canCheckUpdates();
allSectionsSection.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING;
}
}).finally(() => {
@@ -981,7 +978,7 @@ export class CoreCourseHelperProvider {
*/
getCourseStatusIconAndTitleFromStatus(status: string): {icon: string, title: string} {
if (status == CoreConstants.DOWNLOADED) {
- // Always show refresh icon, we cannot knew if there's anything new in course options.
+ // Always show refresh icon, we cannot know if there's anything new in course options.
return {
icon: 'refresh',
title: 'core.course.refreshcourse'
@@ -1330,9 +1327,8 @@ export class CoreCourseHelperProvider {
return this.utils.allPromises(promises).then(() => {
// Set "All sections" data.
- section.showDownload = allSectionsStatus === CoreConstants.NOT_DOWNLOADED;
- section.showRefresh = allSectionsStatus === CoreConstants.OUTDATED ||
- (!this.prefetchDelegate.canCheckUpdates() && allSectionsStatus === CoreConstants.DOWNLOADED);
+ section.downloadStatus = allSectionsStatus;
+ section.canCheckUpdates = this.prefetchDelegate.canCheckUpdates();
section.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING;
}).finally(() => {
section.isDownloading = false;
diff --git a/src/lang/en.json b/src/lang/en.json
index 27e5e170f..d1e2a0c96 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -72,6 +72,7 @@
"dismiss": "Dismiss",
"done": "Done",
"download": "Download",
+ "downloaded": "Downloaded",
"downloading": "Downloading",
"edit": "Edit",
"emptysplit": "This page will appear blank if the left panel is empty or is loading.",