diff --git a/src/core/components/attachments/attachments.scss b/src/core/components/attachments/attachments.scss new file mode 100644 index 000000000..4582f0e2b --- /dev/null +++ b/src/core/components/attachments/attachments.scss @@ -0,0 +1,5 @@ +:host { + core-loading { + --loading-inline-min-height: 60px; + } +} diff --git a/src/core/components/attachments/attachments.ts b/src/core/components/attachments/attachments.ts index 925d71de7..d8e1c6fa0 100644 --- a/src/core/components/attachments/attachments.ts +++ b/src/core/components/attachments/attachments.ts @@ -42,6 +42,7 @@ import { CoreUtils } from '@services/utils/utils'; @Component({ selector: 'core-attachments', templateUrl: 'core-attachments.html', + styleUrls: ['attachments.scss'], }) export class CoreAttachmentsComponent implements OnInit { @@ -59,16 +60,17 @@ export class CoreAttachmentsComponent implements OnInit { maxSubmissionsReadable?: string; unlimitedFiles?: boolean; fileTypes?: CoreFileUploaderTypeList; + loaded = false; /** - * Component being initialized. + * @inheritdoc */ - ngOnInit(): void { + async ngOnInit(): Promise { this.files = this.files || []; this.maxSize = this.maxSize !== null ? Number(this.maxSize) : NaN; if (this.maxSize === 0) { - this.getMaxSizeOfArea(); + await this.getMaxSizeOfArea(); } else if (this.maxSize > 0) { this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2); } else if (this.maxSize === -1) { @@ -90,6 +92,8 @@ export class CoreAttachmentsComponent implements OnInit { if (this.acceptedTypes && this.acceptedTypes != '*') { this.fileTypes = CoreFileUploader.prepareFiletypeList(this.acceptedTypes); } + + this.loaded = true; } /** diff --git a/src/core/components/attachments/core-attachments.html b/src/core/components/attachments/core-attachments.html index f18d06124..3b5cd9371 100644 --- a/src/core/components/attachments/core-attachments.html +++ b/src/core/components/attachments/core-attachments.html @@ -1,37 +1,40 @@ - - - - {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} - - {{ 'core.maxfilesize' | translate:{$a: maxSizeReadable} }} - - - - - -

{{ 'core.fileuploader.filesofthesetypes' | translate }}

-
    -
  • - {{typeInfo.name}} {{typeInfo.extlist}} -
  • -
-
-
-
- - - + + + + + {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} + + {{ 'core.maxfilesize' | translate:{$a: maxSizeReadable} }} + + + + + +

{{ 'core.fileuploader.filesofthesetypes' | translate }}

+
    +
  • + {{typeInfo.name}} {{typeInfo.extlist}} +
  • +
+
+
+
+ + + - - - -
+ + + +
- - - - {{ 'core.fileuploader.addfiletext' | translate }} - + + + + {{ 'core.fileuploader.addfiletext' | translate }} + + diff --git a/src/core/features/fileuploader/services/fileuploader-helper.ts b/src/core/features/fileuploader/services/fileuploader-helper.ts index 33b70931d..0aae60598 100644 --- a/src/core/features/fileuploader/services/fileuploader-helper.ts +++ b/src/core/features/fileuploader/services/fileuploader-helper.ts @@ -204,16 +204,12 @@ export class CoreFileUploaderHelperProvider { // Check that size isn't too large. if (maxSize !== undefined && maxSize != -1) { - try { - const fileEntry = await CoreFile.getExternalFile(path); + const fileEntry = await CoreFile.getExternalFile(path); - const fileData = await CoreFile.getFileObjectFromFileEntry(fileEntry); + const fileData = await CoreFile.getFileObjectFromFileEntry(fileEntry); - if (fileData.size > maxSize) { - throw this.createMaxBytesError(maxSize, fileEntry.name); - } - } catch (error) { - // Ignore failures. + if (fileData.size > maxSize) { + throw this.createMaxBytesError(maxSize, fileEntry.name); } }