mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2368] Version manager update (#3058)
* Add auto file renaming in FE side * Add error handling, file type restriction * Documentation * Fix ts-lint error * Test the service * Fix fdescribe...
This commit is contained in:
committed by
Eugenio Romano
parent
4ee7cc0870
commit
8859d3466e
@@ -23,6 +23,7 @@ export interface FileUploadProgress {
|
||||
|
||||
export interface FileUploadOptions {
|
||||
newVersion?: boolean;
|
||||
newVersionBaseName?: string;
|
||||
parentId?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
@@ -164,6 +164,20 @@ describe('UploadService', () => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().params.has('majorVersion')).toBe(true);
|
||||
});
|
||||
|
||||
it('If newVersionBaseName is set, name should be a param', () => {
|
||||
let emitter = new EventEmitter();
|
||||
|
||||
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 }, {
|
||||
newVersion: true,
|
||||
newVersionBaseName: 'name-under-test'
|
||||
});
|
||||
service.addToQueue(filesFake);
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().params.has('name')).toBe(true);
|
||||
expect(jasmine.Ajax.requests.mostRecent().params.get('name')).toBe('name-under-test');
|
||||
});
|
||||
|
||||
it('should use custom root folder ID given to the service', (done) => {
|
||||
let emitter = new EventEmitter();
|
||||
|
||||
|
@@ -164,6 +164,11 @@ export class UploadService {
|
||||
} else {
|
||||
opts.autoRename = true;
|
||||
}
|
||||
|
||||
if (file.options.newVersionBaseName) {
|
||||
opts.name = file.options.newVersionBaseName;
|
||||
}
|
||||
|
||||
return this.apiService.getInstance().upload.uploadFile(
|
||||
file.file,
|
||||
file.options.path,
|
||||
|
Reference in New Issue
Block a user