[ASD-2483] Validate folder name on change (#3088)

* notify service refactoring
get translate eliminitation in favor of instant
add error event where necessary
fix config problem during test

* fix delete notify test

* remove fdescribe

* fix core test

* errors

* fix types
This commit is contained in:
Eugenio Romano
2018-03-21 16:55:52 +00:00
committed by GitHub
parent de0fdd9ab4
commit 2951374cc0
25 changed files with 357 additions and 260 deletions

View File

@@ -32,7 +32,7 @@ import { Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation }
templateUrl: './upload-drag-area.component.html',
styleUrls: ['./upload-drag-area.component.css'],
viewProviders: [
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)}
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent) }
],
encapsulation: ViewEncapsulation.None
})
@@ -56,6 +56,10 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
@Output()
success = new EventEmitter();
/** Raised when the file upload goes in error. */
@Output()
error = new EventEmitter();
constructor(private uploadService: UploadService,
private translateService: TranslationService,
private notificationService: NotificationService) {
@@ -91,8 +95,8 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
parentId: this.parentId,
path: item.fullPath.replace(item.name, '')
});
this.uploadService.addToQueue(fileModel);
this.uploadService.uploadFilesInTheQueue(this.success);
this.addNodeInUploadQueue([fileModel]);
});
}
}
@@ -112,8 +116,18 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
path: entry.relativeFolder
});
});
this.uploadService.addToQueue(...files);
this.uploadService.uploadFilesInTheQueue(this.success);
this.addNodeInUploadQueue(files);
});
}
}
private addNodeInUploadQueue(files: FileModel[]) {
if (files.length) {
this.uploadService.addToQueue(...files);
this.uploadService.uploadFilesInTheQueue(this.success);
this.uploadService.fileUploadError.subscribe((error) => {
this.error.emit(error);
});
}
}
@@ -133,15 +147,6 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
});
}
/**
* Show the error inside Notification bar
*
* @param Error message
*/
showErrorNotificationBar(errorMessage: string) {
this.notificationService.openSnackMessage(errorMessage, 3000);
}
/** Returns true or false considering the component options and node permissions */
isDroppable(): boolean {
return !this.disabled;
@@ -168,23 +173,11 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
path: fileInfo.relativeFolder,
parentId: parentId
}));
this.uploadFiles(fileModels);
this.addNodeInUploadQueue(fileModels);
}
}
}
/**
* Does the actual file uploading and show the notification
*
* @param files
*/
private uploadFiles(files: FileModel[]): void {
if (files.length) {
this.uploadService.addToQueue(...files);
this.uploadService.uploadFilesInTheQueue(this.success);
}
}
/**
* Check if "create" permission is present on the given node
*