Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/addons/mod_book/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ angular.module('mm.addons.mod_book')
$scope.title = module.name;
$scope.icon = $mmCourse.getModuleIconSrc('book');
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_folder/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ angular.module('mm.addons.mod_folder')
$scope.icon = $mmCourse.getModuleIconSrc('folder');
$scope.title = module.name;
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_imscp/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ angular.module('mm.addons.mod_imscp')
$scope.title = module.name;
$scope.icon = $mmCourse.getModuleIconSrc('imscp');
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_page/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ angular.module('mm.addons.mod_page')
$scope.title = module.name;
$scope.icon = $mmCourse.getModuleIconSrc('page');
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_resource/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ angular.module('mm.addons.mod_resource')
$scope.icon = $mmCourse.getModuleIconSrc('resource');
}
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_scorm/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ angular.module('mm.addons.mod_scorm')
$scope.icon = $mmCourse.getModuleIconSrc('scorm');
$scope.title = module.name;
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
2 changes: 1 addition & 1 deletion www/addons/mod_wiki/services/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ angular.module('mm.addons.mod_wiki')
$scope.title = module.name;
$scope.icon = $mmCourse.getModuleIconSrc('wiki');
$scope.buttons = [downloadBtn, refreshBtn];
$scope.spinner = false;
$scope.spinner = true; // Show spinner while calculating status.

$scope.action = function(e) {
if (e) {
Expand Down
3 changes: 3 additions & 0 deletions www/core/components/course/controllers/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ angular.module('mm.core.course')
e.preventDefault();
e.stopPropagation();

section.isCalculating = true;
$mmCourseHelper.confirmDownloadSize(courseId, section, $scope.sections).then(function() {
prefetch(section, true);
}).finally(function() {
section.isCalculating = false;
});
};

Expand Down
8 changes: 8 additions & 0 deletions www/core/components/course/services/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ angular.module('mm.core.course')
if (section.id === mmCoreCourseAllSectionsId) {
// "All sections" section status is calculated using the status of the rest of sections.
allsectionssection = section;
section.isCalculating = true;
} else {
section.isCalculating = true;
statuspromises.push(self.calculateSectionStatus(section, courseid, restoreDownloads, refresh, downloadpromises)
.then(function(result) {

// Calculate "All sections" status.
allsectionsstatus = $mmFilepool.determinePackagesStatus(allsectionsstatus, result.status);
}).finally(function() {
section.isCalculating = false;
}));
}
});
Expand All @@ -125,6 +129,10 @@ angular.module('mm.core.course')
allsectionssection.isDownloading = allsectionsstatus === mmCoreDownloading;
}
return downloadpromises;
}).finally(function() {
if (allsectionssection) {
allsectionssection.isCalculating = false;
}
});
};

Expand Down
6 changes: 3 additions & 3 deletions www/core/components/course/templates/sections.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<a class="item item-text-wrap item-button-right" mm-split-view-link="site.mm_course-section({cid: courseId, sectionid: section.id, mid: moduleId})" title="{{section.name}}">
<mm-format-text watch="true">{{section.name}}</mm-format-text>

<button ng-if="section.showDownload && !section.isDownloading" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.download' | translate }}">
<button ng-if="section.showDownload && !section.isDownloading && !section.isCalculating" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.download' | translate }}">
<i class="icon ion-ios-cloud-download-outline"></i>
</button>
<button ng-if="section.showRefresh && !section.isDownloading" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.refresh' | translate }}">
<button ng-if="section.showRefresh && !section.isDownloading && !section.isCalculating" ng-click="prefetch($event, section)" class="button button-icon" aria-label="{{ 'mm.core.refresh' | translate }}">
<i class="icon ion-android-refresh"></i>
</button>

<ion-spinner ng-if="section.isDownloading && section.total > 0"></ion-spinner>
<ion-spinner ng-if="(section.isDownloading && section.total > 0) || section.isCalculating"></ion-spinner>
<span class="badge mm-course-download" ng-if="section.isDownloading && section.total > 0 && section.count < section.total">{{section.count}} / {{section.total}}</span>
</a>
</li>
Expand Down