Skip to content

Commit

Permalink
MOBILE-4406 course-storage: Hide downloaded button from resources typ…
Browse files Browse the repository at this point in the history
…e label
  • Loading branch information
alfonso-salces committed Sep 22, 2023
1 parent 9f23108 commit 645b778
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/addons/storagemanager/pages/course-storage/course-storage.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>

<ion-card class="wholecourse">
<ion-card-header>
<ion-card-title>{{ title }}</ion-card-title>
<ion-card-title>
<core-format-text [text]="title" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text>
</ion-card-title>
<ion-item class="size ion-text-wrap ion-no-padding">
<ion-label>
<p class="item-heading ion-text-wrap">{{ 'addon.storagemanager.totaldownloads' | translate }}</p>
Expand Down Expand Up @@ -77,7 +80,7 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>
</ion-label>
<div class="storage-buttons" slot="end"
*ngIf="(!section.calculatingSize && section.totalSize > 0) || downloadEnabled">
<div *ngIf="downloadEnabled" slot="end" class="core-button-spinner">
<div *ngIf="downloadEnabled && canDownloadSection(section)" slot="end" class="core-button-spinner">
<core-download-refresh *ngIf="!section.isDownloading && section.downloadStatus != statusDownloaded"
[status]="section.downloadStatus" [enabled]="true" (action)="prefecthSection(section)"
[loading]="section.isDownloading || section.isCalculating" [canTrustDownload]="true">
Expand Down Expand Up @@ -126,17 +129,18 @@ <h1>{{ 'addon.storagemanager.coursedownloads' | translate }}</h1>

<div class="storage-buttons" slot="end">
<core-download-refresh *ngIf="downloadEnabled && module.handlerData?.showDownloadButton &&
module.downloadStatus != statusDownloaded" [status]="module.downloadStatus" [enabled]="true"
[canTrustDownload]="true" [loading]="module.spinner || module.handlerData.spinner"
(action)="prefetchModule(module)">
module.downloadStatus != statusDownloaded && module.modname !== 'label'"
[status]="module.downloadStatus" [enabled]="true" [canTrustDownload]="true"
[loading]="module.spinner || module.handlerData.spinner" (action)="prefetchModule(module)">
</core-download-refresh>
<ion-button fill="clear" (click)="deleteForModule($event, module, section)"
*ngIf="!module.calculatingSize && module.totalSize > 0" color="danger">
<ion-icon name="fas-trash" slot="icon-only"
[attr.aria-label]="'addon.storagemanager.deletedatafrom' | translate: { name: module.name }">
</ion-icon>
</ion-button>
<p *ngIf="!downloadEnabled || !module.handlerData?.showDownloadButton" class="sr-only">
<p *ngIf="(!downloadEnabled || !module.handlerData?.showDownloadButton) && module.modname === 'label'"
class="sr-only">
{{ 'core.notdownloadable' | translate }}
</p>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/addons/storagemanager/pages/course-storage/course-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,16 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
}
}

/**
* Check if the provided section can be downloaded.
*
* @param section Section to check.
* @returns Can be downloaded or not.
*/
canDownloadSection(section: AddonStorageManagerCourseSection): boolean {
return section.modules.some(module => module.modname !== 'label');
}

/**
* Toggle expand status.
*
Expand Down

0 comments on commit 645b778

Please sign in to comment.