diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 391cb9b50..70be9851c 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1861,6 +1861,7 @@ "core.mainmenu.help": "Help", "core.mainmenu.logout": "Log out", "core.mainmenu.website": "Website", + "core.maxfilesize": "Maximum size for new files: {{$a}}", "core.maxsizeandattachments": "Maximum file size: {{$a.size}}, maximum number of files: {{$a.attachments}}", "core.min": "min", "core.mins": "mins", diff --git a/src/components/attachments/attachments.ts b/src/components/attachments/attachments.ts index 810165c39..e327db8a6 100644 --- a/src/components/attachments/attachments.ts +++ b/src/components/attachments/attachments.ts @@ -39,8 +39,8 @@ import { CoreFileUploaderHelperProvider } from '@core/fileuploader/providers/hel }) export class CoreAttachmentsComponent implements OnInit { @Input() files: any[]; // List of attachments. New attachments will be added to this array. - @Input() maxSize: number; // Max size for attachments. If not defined, 0 or -1, unknown size. - @Input() maxSubmissions: number; // Max number of attachments. If -1 or not defined, unknown limit. + @Input() maxSize: number; // Max size for attachments. -1 means unlimited, not defined or 0 means unknown limit. + @Input() maxSubmissions: number; // Max number of attachments. -1 means unlimited, not defined means unknown limit. @Input() component: string; // Component the downloaded files will be linked to. @Input() componentId: string | number; // Component ID. @Input() allowOffline: boolean | string; // Whether to allow selecting files in offline. @@ -61,17 +61,18 @@ export class CoreAttachmentsComponent implements OnInit { * Component being initialized. */ ngOnInit(): void { - this.maxSize = Number(this.maxSize); // Make sure it's defined and it's a number. - this.maxSize = !isNaN(this.maxSize) && this.maxSize > 0 ? this.maxSize : -1; + this.maxSize = Number(this.maxSize) || 0; // Make sure it's defined and it's a number. - if (this.maxSize == -1) { + if (this.maxSize === 0) { this.maxSizeReadable = this.translate.instant('core.unknown'); - } else { + } else if (this.maxSize > 0) { this.maxSizeReadable = this.textUtils.bytesToSize(this.maxSize, 2); + } else { + this.maxSizeReadable = this.translate.instant('core.unlimited'); } if (typeof this.maxSubmissions == 'undefined' || this.maxSubmissions < 0) { - this.maxSubmissionsReadable = this.translate.instant('core.unknown'); + this.maxSubmissionsReadable = this.maxSubmissions < 0 ? undefined : this.translate.instant('core.unknown'); this.unlimitedFiles = true; } else { this.maxSubmissionsReadable = String(this.maxSubmissions); diff --git a/src/components/attachments/core-attachments.html b/src/components/attachments/core-attachments.html index 7a1abcda8..f57780bad 100644 --- a/src/components/attachments/core-attachments.html +++ b/src/components/attachments/core-attachments.html @@ -1,5 +1,6 @@ - {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} + {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} + {{ 'core.maxfilesize' | translate:{$a: maxSizeReadable} }} diff --git a/src/lang/en.json b/src/lang/en.json index c6c46dc48..2a1dc13f5 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -143,6 +143,7 @@ "loadmore": "Load more", "location": "Location", "lostconnection": "Your authentication token is invalid or has expired. You will have to reconnect to the site.", + "maxfilesize": "Maximum size for new files: {{$a}}", "maxsizeandattachments": "Maximum file size: {{$a.size}}, maximum number of files: {{$a.attachments}}", "min": "min", "mins": "mins", diff --git a/upgrade.txt b/upgrade.txt index f66263f6a..1f2e73f6f 100644 --- a/upgrade.txt +++ b/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in the Moodle Mobile app, information provided here is intended especially for developers. +=== 3.9.3 === + +- In the core-attachments component, passing a -1 as maxSize or maxSubmissions used to mean "unknown limit". Now -1 means unlimited. + === 3.8.3 === - CoreFileProvider.writeFileDataInFile has been deprecated. Please use CoreFileHelperProvider.writeFileDataInFile instead.