MOBILE-2272 attachments: Make -1 mean unlimited in size and files
parent
f780b3afc3
commit
b6ed831b25
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<ion-item text-wrap>
|
||||
{{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }}
|
||||
<span *ngIf="maxSubmissionsReadable">{{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }}</span>
|
||||
<span *ngIf="!maxSubmissionsReadable">{{ 'core.maxfilesize' | translate:{$a: maxSizeReadable} }}</span>
|
||||
<span [core-mark-required]="required" class="core-mark-required"></span>
|
||||
</ion-item>
|
||||
<ion-item text-wrap *ngIf="fileTypes && fileTypes.mimetypes && fileTypes.mimetypes.length">
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue