Skip to content

Commit d1856f5

Browse files
committed
MOBILE-4660 course: Adapt course downloads to new data structure
1 parent d384752 commit d1856f5

File tree

13 files changed

+252
-418
lines changed

13 files changed

+252
-418
lines changed

src/addons/block/activitymodules/components/activitymodules/activitymodules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
7070
let modFullNames: Record<string, string> = {};
7171
const brandedIcons: Record<string, boolean|undefined> = {};
7272

73-
const modules = CoreCourseHelper.getSectionsModules(sections, {
73+
const modules = CoreCourse.getSectionsModules(sections, {
7474
ignoreSection: section => !CoreCourseHelper.canUserViewSection(section),
7575
ignoreModule: module => !CoreCourseHelper.canUserViewModule(module) || !CoreCourse.moduleHasView(module),
7676
});

src/addons/mod/subsection/constants.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/addons/mod/subsection/services/handlers/prefetch.ts

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/addons/mod/subsection/subsection.module.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import { APP_INITIALIZER, NgModule } from '@angular/core';
1616
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
1717
import { AddonModSubsectionIndexLinkHandler } from './services/handlers/index-link';
18-
import { AddonModSubsectionPrefetchHandler } from './services/handlers/prefetch';
19-
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
2018

2119
@NgModule({
2220
providers: [
@@ -25,7 +23,6 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
2523
multi: true,
2624
useValue: () => {
2725
CoreContentLinksDelegate.registerHandler(AddonModSubsectionIndexLinkHandler.instance);
28-
CoreCourseModulePrefetchDelegate.registerHandler(AddonModSubsectionPrefetchHandler.instance);
2926
},
3027
},
3128
],

src/addons/storagemanager/pages/course-storage/course-storage.html

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>
1616
</ion-label>
1717
</ion-item>
1818

19-
2019
<ion-card class="wholecourse">
2120
<ion-card-header>
2221
<ion-card-title>
@@ -57,7 +56,7 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>
5756

5857

5958
<ng-template #sectionCard let-section="section">
60-
<ion-card class="section" *ngIf="section.modules.length > 0" [id]="'addons-course-storage-'+section.id">
59+
<ion-card class="section" *ngIf="section.contents.length > 0" [id]="'addons-course-storage-'+section.id">
6160
<ion-accordion [value]="section.id" toggleIconSlot="start">
6261
<ion-item [detail]="false" slot="header" class="card-header">
6362
<ion-label>
@@ -102,45 +101,46 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>
102101
</ion-item>
103102
<ion-card-content slot="content">
104103
<ng-container *ngIf="section.expanded">
105-
<ng-container *ngFor="let module of section.modules">
106-
@if (module.subSection) {
107-
<ng-container *ngTemplateOutlet="sectionCard; context: { section: module.subSection }" />
104+
<ng-container *ngFor="let modOrSubsection of section.contents">
105+
@if (!isModule(modOrSubsection)) {
106+
<ng-container *ngTemplateOutlet="sectionCard; context: { section: modOrSubsection }" />
108107
} @else {
109108
<ion-item class="core-course-storage-activity"
110-
*ngIf="downloadEnabled || (!module.calculatingSize && module.totalSize > 0)">
111-
<core-mod-icon slot="start" *ngIf="module.handlerData.icon" [modicon]="module.handlerData.icon"
112-
[modname]="module.modname" [componentId]="module.instance" [fallbackTranslation]="module.modplural"
113-
[isBranded]="module.branded" />
109+
*ngIf="downloadEnabled || (!modOrSubsection.calculatingSize && modOrSubsection.totalSize > 0)">
110+
<core-mod-icon slot="start" *ngIf="modOrSubsection.handlerData.icon"
111+
[modicon]="modOrSubsection.handlerData.icon" [modname]="modOrSubsection.modname"
112+
[componentId]="modOrSubsection.instance" [fallbackTranslation]="modOrSubsection.modplural"
113+
[isBranded]="modOrSubsection.branded" />
114114
<ion-label class="ion-text-wrap">
115-
<p class="item-heading {{module.handlerData!.class}} addon-storagemanager-module-size">
116-
<core-format-text [text]="module.handlerData.title" [courseId]="module.course" contextLevel="module"
117-
[contextInstanceId]="module.id" [adaptImg]="false" />
115+
<p class="item-heading {{modOrSubsection.handlerData!.class}} addon-storagemanager-module-size">
116+
<core-format-text [text]="modOrSubsection.handlerData.title" [courseId]="modOrSubsection.course"
117+
contextLevel="module" [contextInstanceId]="modOrSubsection.id" [adaptImg]="false" />
118118
</p>
119-
<ion-badge [color]="module.downloadStatus === statusDownloaded ? 'success' : 'light'"
120-
*ngIf="!module.calculatingSize && module.totalSize > 0">
121-
<ion-icon name="fam-cloud-done" *ngIf="module.downloadStatus === statusDownloaded"
122-
[attr.aria-label]="'core.downloaded' | translate" />{{ module.totalSize |
119+
<ion-badge [color]="modOrSubsection.downloadStatus === statusDownloaded ? 'success' : 'light'"
120+
*ngIf="!modOrSubsection.calculatingSize && modOrSubsection.totalSize > 0">
121+
<ion-icon name="fam-cloud-done" *ngIf="modOrSubsection.downloadStatus === statusDownloaded"
122+
[attr.aria-label]="'core.downloaded' | translate" />{{ modOrSubsection.totalSize |
123123
coreBytesToSize }}
124124
</ion-badge>
125-
<ion-badge color="light" *ngIf="module.calculatingSize ||
126-
(section.isDownloading && module.downloadStatus === statusDownloaded)">
125+
<ion-badge color="light" *ngIf="modOrSubsection.calculatingSize ||
126+
(section.isDownloading && modOrSubsection.downloadStatus === statusDownloaded)">
127127
{{ 'core.calculating' | translate }}
128128
</ion-badge>
129129
</ion-label>
130130

131131
<div class="storage-buttons" slot="end">
132-
<core-download-refresh *ngIf="downloadEnabled && module.handlerData?.showDownloadButton &&
133-
module.downloadStatus !== statusDownloaded" [status]="module.downloadStatus" [enabled]="true"
134-
[canTrustDownload]="true" [loading]="module.spinner || module.handlerData.spinner"
135-
(action)="prefetchModule(module)"
132+
<core-download-refresh *ngIf="downloadEnabled && modOrSubsection.handlerData?.showDownloadButton &&
133+
modOrSubsection.downloadStatus !== statusDownloaded" [status]="modOrSubsection.downloadStatus" [enabled]="true"
134+
[canTrustDownload]="true" [loading]="modOrSubsection.spinner || modOrSubsection.handlerData.spinner"
135+
(action)="prefetchModule(modOrSubsection)"
136136
[statusesTranslatable]="{notdownloaded: 'addon.storagemanager.downloaddatafrom' }"
137-
[statusSubject]="module.name" />
138-
<ion-button fill="clear" (click)="deleteForModule($event, module)"
139-
*ngIf="!module.calculatingSize && module.totalSize > 0" color="danger">
137+
[statusSubject]="modOrSubsection.name" />
138+
<ion-button fill="clear" (click)="deleteForModule($event, modOrSubsection)"
139+
*ngIf="!modOrSubsection.calculatingSize && modOrSubsection.totalSize > 0" color="danger">
140140
<ion-icon name="fas-trash" slot="icon-only" [attr.aria-label]="
141-
'addon.storagemanager.deletedatafrom' | translate: { name: module.name }" />
141+
'addon.storagemanager.deletedatafrom' | translate: { name: modOrSubsection.name }" />
142142
</ion-button>
143-
<p *ngIf="!downloadEnabled || !module.handlerData?.showDownloadButton" class="sr-only">
143+
<p *ngIf="!downloadEnabled || !modOrSubsection.handlerData?.showDownloadButton" class="sr-only">
144144
{{ 'core.notdownloadable' | translate }}
145145
</p>
146146
</div>

0 commit comments

Comments
 (0)