@@ -39,8 +39,8 @@ import { CoreFileUploaderHelperProvider } from '@core/fileuploader/providers/hel
3939} )
4040export class CoreAttachmentsComponent implements OnInit {
4141 @Input ( ) files : any [ ] ; // List of attachments. New attachments will be added to this array.
42- @Input ( ) maxSize : number ; // Max size for attachments. If not defined, 0 or -1, unknown size .
43- @Input ( ) maxSubmissions : number ; // Max number of attachments. If -1 or not defined, unknown limit.
42+ @Input ( ) maxSize : number ; // Max size for attachments. -1 means unlimited, not defined or 0 means unknown limit .
43+ @Input ( ) maxSubmissions : number ; // Max number of attachments. -1 means unlimited, not defined means unknown limit.
4444 @Input ( ) component : string ; // Component the downloaded files will be linked to.
4545 @Input ( ) componentId : string | number ; // Component ID.
4646 @Input ( ) allowOffline : boolean | string ; // Whether to allow selecting files in offline.
@@ -61,17 +61,18 @@ export class CoreAttachmentsComponent implements OnInit {
6161 * Component being initialized.
6262 */
6363 ngOnInit ( ) : void {
64- this . maxSize = Number ( this . maxSize ) ; // Make sure it's defined and it's a number.
65- this . maxSize = ! isNaN ( this . maxSize ) && this . maxSize > 0 ? this . maxSize : - 1 ;
64+ this . maxSize = Number ( this . maxSize ) || 0 ; // Make sure it's defined and it's a number.
6665
67- if ( this . maxSize == - 1 ) {
66+ if ( this . maxSize === 0 ) {
6867 this . maxSizeReadable = this . translate . instant ( 'core.unknown' ) ;
69- } else {
68+ } else if ( this . maxSize > 0 ) {
7069 this . maxSizeReadable = this . textUtils . bytesToSize ( this . maxSize , 2 ) ;
70+ } else {
71+ this . maxSizeReadable = this . translate . instant ( 'core.unlimited' ) ;
7172 }
7273
7374 if ( typeof this . maxSubmissions == 'undefined' || this . maxSubmissions < 0 ) {
74- this . maxSubmissionsReadable = this . translate . instant ( 'core.unknown' ) ;
75+ this . maxSubmissionsReadable = this . maxSubmissions < 0 ? undefined : this . translate . instant ( 'core.unknown' ) ;
7576 this . unlimitedFiles = true ;
7677 } else {
7778 this . maxSubmissionsReadable = String ( this . maxSubmissions ) ;
0 commit comments