mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1711] The <adf-task-attachment-list component displays drag-and-… (#2716)
* [ADF-1711] The <adf-task-attachment-list component displays drag-and-drop area that is not working * fix test for remove upload deprecated properties * remove duplicate identifier
This commit is contained in:
committed by
Maurizio Vitale
parent
083f40192c
commit
dd7a6565e3
@@ -90,7 +90,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
describe('When disabled', () => {
|
||||
|
||||
it('should NOT upload the list of files dropped', () => {
|
||||
component.enabled = false;
|
||||
component.disabled = true;
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
@@ -104,7 +104,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT upload the file dropped', () => {
|
||||
component.enabled = false;
|
||||
component.disabled = true;
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
@@ -126,7 +126,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT upload the folder dropped', (done) => {
|
||||
component.enabled = false;
|
||||
component.disabled = true;
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
@@ -151,7 +151,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT upload the files', () => {
|
||||
component.enabled = false;
|
||||
component.disabled = true;
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
|
||||
@@ -178,9 +178,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should upload the list of files dropped', (done) => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.success = null;
|
||||
component.showNotificationBar = false;
|
||||
uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -195,24 +193,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
component.onFilesDropped(filesList);
|
||||
});
|
||||
|
||||
it('should show the loading messages in the notification bar when the files are dropped', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.success = null;
|
||||
component.showNotificationBar = true;
|
||||
uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
component.showUndoNotificationBar = jasmine.createSpy('_showUndoNotificationBar');
|
||||
|
||||
fixture.detectChanges();
|
||||
let fileFake = <File> {name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json'};
|
||||
let filesList = [fileFake];
|
||||
|
||||
component.onFilesDropped(filesList);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith(null);
|
||||
expect(component.showUndoNotificationBar).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should upload a file when dropped', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake';
|
||||
component.success = null;
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -234,8 +215,6 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should upload a file with a custom root folder ID when dropped', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.success = null;
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -257,10 +236,6 @@ describe('UploadDragAreaComponent', () => {
|
||||
});
|
||||
|
||||
it('should upload a file when user has create permission on target folder', async(() => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.enabled = false;
|
||||
|
||||
let fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
@@ -287,29 +262,4 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
}));
|
||||
|
||||
it('should show notification bar when a file is dropped', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.success = null;
|
||||
|
||||
fixture.detectChanges();
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
|
||||
let itemEntity = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
isDirectory: false,
|
||||
isFile: true,
|
||||
name: 'file-fake.png',
|
||||
file: (callbackFile) => {
|
||||
let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'});
|
||||
callbackFile(fileFake);
|
||||
}
|
||||
};
|
||||
|
||||
component.onFilesEntityDropped(itemEntity);
|
||||
fixture.detectChanges();
|
||||
expect(document.querySelector('snack-bar-container > simple-snack-bar')).not.toBeNull();
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -38,31 +38,6 @@ import { Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation }
|
||||
})
|
||||
export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
|
||||
/** @deprecated Deprecated in favor of disabled input property */
|
||||
@Input()
|
||||
set enabled(enabled: boolean) {
|
||||
console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.');
|
||||
this.disabled = !enabled;
|
||||
}
|
||||
|
||||
/** @deprecated Deprecated in favor of disabled input property */
|
||||
get enabled(): boolean {
|
||||
console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.');
|
||||
return !this.disabled;
|
||||
}
|
||||
|
||||
/** @deprecated Deprecated in 1.6.0, you can use UploadService events and NotificationService api instead. */
|
||||
@Input()
|
||||
showNotificationBar: boolean = true;
|
||||
|
||||
/** @deprecated Deprecated in 1.6.0, this property is not used for couple of releases already. Use rootFolderId instead. */
|
||||
@Input()
|
||||
currentFolderPath: string = '/';
|
||||
|
||||
/** @deprecated Deprecated in 1.6.2, this property is not used for couple of releases already. Use parentId instead. */
|
||||
@Input()
|
||||
rootFolderId: string = '-root-';
|
||||
|
||||
@Input()
|
||||
disabled: boolean = false;
|
||||
|
||||
@@ -90,14 +65,10 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
const fileModels = files.map(file => new FileModel(file, {
|
||||
newVersion: this.versioning,
|
||||
path: '/',
|
||||
parentId: this.parentId || this.rootFolderId
|
||||
parentId: this.parentId
|
||||
}));
|
||||
this.uploadService.addToQueue(...fileModels);
|
||||
this.uploadService.uploadFilesInTheQueue(this.success);
|
||||
let latestFilesAdded = this.uploadService.getQueue();
|
||||
if (this.showNotificationBar) {
|
||||
this.showUndoNotificationBar(latestFilesAdded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,15 +82,12 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
item.file((file: File) => {
|
||||
const fileModel = new FileModel(file, {
|
||||
newVersion: this.versioning,
|
||||
parentId: this.parentId || this.rootFolderId,
|
||||
parentId: this.parentId,
|
||||
path: item.fullPath.replace(item.name, '')
|
||||
});
|
||||
this.uploadService.addToQueue(fileModel);
|
||||
this.uploadService.uploadFilesInTheQueue(this.success);
|
||||
});
|
||||
if (this.showNotificationBar) {
|
||||
this.showUndoNotificationBar(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,16 +102,11 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
let files = entries.map(entry => {
|
||||
return new FileModel(entry.file, {
|
||||
newVersion: this.versioning,
|
||||
parentId: this.parentId || this.rootFolderId,
|
||||
parentId: this.parentId,
|
||||
path: entry.relativeFolder
|
||||
});
|
||||
});
|
||||
this.uploadService.addToQueue(...files);
|
||||
/* @deprecated in 1.6.0 */
|
||||
if (this.showNotificationBar) {
|
||||
let latestFilesAdded = this.uploadService.getQueue();
|
||||
this.showUndoNotificationBar(latestFilesAdded);
|
||||
}
|
||||
this.uploadService.uploadFilesInTheQueue(this.success);
|
||||
});
|
||||
}
|
||||
@@ -191,9 +154,9 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
if (isAllowed) {
|
||||
let files: FileInfo[] = event.detail.files;
|
||||
if (files && files.length > 0) {
|
||||
let parentId = this.parentId || this.rootFolderId;
|
||||
let parentId = this.parentId;
|
||||
if (event.detail.data && event.detail.data.obj.entry.isFolder) {
|
||||
parentId = event.detail.data.obj.entry.id || this.parentId || this.rootFolderId;
|
||||
parentId = event.detail.data.obj.entry.id || this.parentId;
|
||||
}
|
||||
const fileModels = files.map(fileInfo => new FileModel(fileInfo.file, {
|
||||
newVersion: this.versioning,
|
||||
@@ -214,10 +177,6 @@ export class UploadDragAreaComponent implements NodePermissionSubject {
|
||||
if (files.length) {
|
||||
this.uploadService.addToQueue(...files);
|
||||
this.uploadService.uploadFilesInTheQueue(this.success);
|
||||
let latestFilesAdded = this.uploadService.getQueue();
|
||||
if (this.showNotificationBar) {
|
||||
this.showUndoNotificationBar(latestFilesAdded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user