From dcba760c684855707893ab79ef5e26d7035b46be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 22 Jul 2024 13:53:47 +0200 Subject: [PATCH] MOBILE-4628 course-storage: Better translate status on download refresh --- .../pages/course-storage/course-storage.html | 6 ++-- .../core-download-refresh.html | 12 ++++--- .../download-refresh/download-refresh.ts | 35 +++++++++++++++++-- .../core-courses-course-list-item.html | 4 +-- .../course-list-item/course-list-item.ts | 7 ++++ 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.html b/src/addons/storagemanager/pages/course-storage/course-storage.html index 9bcdd56fe..02a86c28b 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.html +++ b/src/addons/storagemanager/pages/course-storage/course-storage.html @@ -78,7 +78,8 @@ + [statusesTranslatable]="{notdownloaded: 'addon.storagemanager.downloaddatafrom' }" + [statusSubject]="section.name" /> + [statusesTranslatable]="{notdownloaded: 'addon.storagemanager.downloaddatafrom' }" + [statusSubject]="module.name" /> + [ariaLabel]="(statusTranslatable || translates.notdownloaded) | translate: { name : statusSubject }"> + (click)="download($event, true)" @coreShowHideAnimation + [ariaLabel]="(statusTranslatable || translates.outdated) | translate: { name : statusSubject }"> + name="fam-cloud-done" [attr.aria-label]="(statusTranslatable || translates.downloaded) | translate: { name : statusSubject }" + role="status" /> + [attr.aria-label]="(statusTranslatable || translates.downloading) | translate: { name : statusSubject }" /> - + diff --git a/src/core/components/download-refresh/download-refresh.ts b/src/core/components/download-refresh/download-refresh.ts index 13f67a5a8..31ae04256 100644 --- a/src/core/components/download-refresh/download-refresh.ts +++ b/src/core/components/download-refresh/download-refresh.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core'; import { DownloadStatus } from '@/core/constants'; import { CoreAnimations } from '@components/animations'; @@ -29,24 +29,45 @@ import { CoreAnimations } from '@components/animations'; styleUrls: ['download-refresh.scss'], animations: [CoreAnimations.SHOW_HIDE], }) -export class CoreDownloadRefreshComponent { +export class CoreDownloadRefreshComponent implements OnInit { @Input() status?: DownloadStatus; // Download status. - @Input() statusTranslatable?: string; // Download status translatable string. + @Input() statusesTranslatable?: Partial; // Download statuses translatable strings. + @Input() statusSubject = ''; // Status subject to use on name filed in the translatable string. @Input() enabled = false; // Whether the download is enabled. @Input() loading = true; // Force loading status when is not downloading. @Input() canTrustDownload = false; // If false, refresh will be shown if downloaded. @Output() action: EventEmitter; // Will emit an event when the item clicked. + /** + * @deprecated since 4.5. Use statusesTranslatable instead. + */ + @Input() statusTranslatable?: string; // Download status translatable string. + statusDownloaded = DownloadStatus.DOWNLOADED; statusNotDownloaded = DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED; statusOutdated = DownloadStatus.OUTDATED; statusDownloading = DownloadStatus.DOWNLOADING; + translates: CoreDownloadStatusTranslatable = { + downloaded: 'core.downloaded', + notdownloaded: 'core.download', + outdated: 'core.refresh', + downloading: 'core.downloading', + loading: 'core.loading', + }; + constructor() { this.action = new EventEmitter(); } + /** + * @inheritdoc + */ + ngOnInit(): void { + this.translates = Object.assign(this.translates, this.statusesTranslatable || {}); + } + /** * Download clicked. * @@ -61,3 +82,11 @@ export class CoreDownloadRefreshComponent { } } + +export type CoreDownloadStatusTranslatable = { + downloaded: string; + notdownloaded: string; + outdated: string; + downloading: string; + loading: string; +}; diff --git a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html index bab879214..26103bc0e 100644 --- a/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html +++ b/src/core/features/courses/components/course-list-item/core-courses-course-list-item.html @@ -10,8 +10,8 @@
+ [statusesTranslatable]="statusesTranslatable" [canTrustDownload]="false" [loading]="prefetchCourseData.loading" + (action)="prefetchCourse()" />
diff --git a/src/core/features/courses/components/course-list-item/course-list-item.ts b/src/core/features/courses/components/course-list-item/course-list-item.ts index 6c494ecd4..ebf2a8bdd 100644 --- a/src/core/features/courses/components/course-list-item/course-list-item.ts +++ b/src/core/features/courses/components/course-list-item/course-list-item.ts @@ -27,6 +27,7 @@ import { CoreCourseListItem, CoreCourses, CoreCoursesProvider } from '../../serv import { CoreCoursesHelper, CoreEnrolledCourseDataWithExtraInfoAndOptions } from '../../services/courses-helper'; import { CoreCoursesCourseOptionsMenuComponent } from '../course-options-menu/course-options-menu'; import { CoreEnrolHelper } from '@features/enrol/services/enrol-helper'; +import { CoreDownloadStatusTranslatable } from '@components/download-refresh/download-refresh'; /** * This directive is meant to display an item for a list of courses. @@ -55,6 +56,12 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On loading: true, }; + statusesTranslatable: Partial = { + downloaded: 'core.course.refreshcourse', + notdownloaded: 'core.course.downloadcourse', + outdated: 'core.course.downloadcourse', + }; + showSpinner = false; courseOptionMenuEnabled = false; progress = -1;