mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2975] New input for File Upload Button component (#3299)
* new nodeType input * unit tests * content type fix * remove package-lock.json files
This commit is contained in:
committed by
Eugenio Romano
parent
97f888d49c
commit
4c7a63c95a
@@ -39,6 +39,7 @@ Activates a file upload.
|
||||
| tooltip | `string` | null | Custom tooltip text. |
|
||||
| uploadFolders | `boolean` | false | Allows/disallows upload folders (only for Chrome). |
|
||||
| versioning | `boolean` | false | Toggles versioning. |
|
||||
| nodeType | `string` | "cm:content" | Custom node type for uploaded file. |
|
||||
|
||||
### Events
|
||||
|
||||
|
@@ -24,7 +24,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-upload-button-test',
|
||||
template: 'test componente';
|
||||
template: 'test componente'
|
||||
})
|
||||
|
||||
export class UploadTestComponent extends UploadBase {
|
||||
@@ -214,11 +214,12 @@ describe('UploadBase', () => {
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: 'example-comment'
|
||||
comment: 'example-comment',
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -246,7 +247,8 @@ describe('UploadBase', () => {
|
||||
newVersion: true,
|
||||
majorVersion: true,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -261,7 +263,49 @@ describe('UploadBase', () => {
|
||||
newVersion: true,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: ''
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Node Type', () => {
|
||||
|
||||
let addToQueueSpy;
|
||||
|
||||
const files: File[] = [
|
||||
<File> { name: 'process.pbmn' }
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
addToQueueSpy = spyOn(uploadService, 'addToQueue');
|
||||
});
|
||||
|
||||
it('should have custom nodeType if it is set', () => {
|
||||
component.nodeType = 'ama:process';
|
||||
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: undefined,
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: '',
|
||||
nodeType: 'ama:process'
|
||||
}));
|
||||
});
|
||||
|
||||
it('should have default nodeType if it is not set', () => {
|
||||
component.uploadFiles(files);
|
||||
|
||||
expect(addToQueueSpy).toHaveBeenCalledWith(new FileModel(files[0], {
|
||||
comment: undefined,
|
||||
newVersion: false,
|
||||
majorVersion: false,
|
||||
parentId: '-root-',
|
||||
path: '',
|
||||
nodeType: 'cm:content'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -53,6 +53,10 @@ export abstract class UploadBase {
|
||||
@Input()
|
||||
comment: string;
|
||||
|
||||
/** Custom node type for uploaded file */
|
||||
@Input()
|
||||
nodeType: string = 'cm:content';
|
||||
|
||||
/** Emitted when the file is uploaded successfully. */
|
||||
@Output()
|
||||
success = new EventEmitter();
|
||||
@@ -139,7 +143,8 @@ export abstract class UploadBase {
|
||||
majorVersion: this.majorVersion,
|
||||
newVersion: this.versioning,
|
||||
parentId: parentId,
|
||||
path: path
|
||||
path: path,
|
||||
nodeType: this.nodeType
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,7 @@ export interface FileUploadOptions {
|
||||
newVersionBaseName?: string;
|
||||
parentId?: string;
|
||||
path?: string;
|
||||
nodeType?: string;
|
||||
}
|
||||
|
||||
export enum FileUploadStatus {
|
||||
|
@@ -172,6 +172,10 @@ export class UploadService {
|
||||
opts.name = file.options.newVersionBaseName;
|
||||
}
|
||||
|
||||
if (file.options.nodeType) {
|
||||
opts.nodeType = file.options.nodeType;
|
||||
}
|
||||
|
||||
return this.apiService.getInstance().upload.uploadFile(
|
||||
file.file,
|
||||
file.options.path,
|
||||
|
20789
package-lock.json
generated
20789
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user