[ADF-2170] fixed condition for file size equal zero (#2860)

* [ADF-2170] fixed condition for file size equal zero

* [ADF-2170] refactored if condition
This commit is contained in:
Vito
2018-01-22 17:52:02 +01:00
committed by Eugenio Romano
parent b65440b490
commit b481bde483
2 changed files with 24 additions and 1 deletions

View File

@@ -201,7 +201,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
private isFileSizeAcceptable(file: FileModel): boolean {
let acceptableSize = true;
if ((this.maxFilesSize !== undefined && this.maxFilesSize !== null ) && (this.maxFilesSize <= 0 || file.size > this.maxFilesSize)) {
if (this.isFileSizeAllowed(file)) {
acceptableSize = false;
this.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => {
@@ -212,6 +212,18 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
return acceptableSize;
}
private isFileSizeAllowed(file: FileModel) {
return this.isMaxFileSizeDefined() && this.isFileSizeCorrect(file);
}
private isMaxFileSizeDefined() {
return this.maxFilesSize !== undefined && this.maxFilesSize !== null;
}
private isFileSizeCorrect(file: FileModel) {
return this.maxFilesSize < 0 || file.size > this.maxFilesSize;
}
checkPermission() {
if (this.rootFolderId) {
this.getFolderNode(this.rootFolderId).subscribe(