mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4794] Not able to attach a second file to a form after one has already been attached (#5058)
This commit is contained in:
@@ -71,12 +71,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.field &&
|
super.ngOnInit();
|
||||||
this.field.value &&
|
|
||||||
this.field.value.length > 0) {
|
|
||||||
this.hasFile = true;
|
|
||||||
}
|
|
||||||
this.getMultipleFileParam();
|
|
||||||
|
|
||||||
this.activitiContentService.getAlfrescoRepositories(null, true).subscribe((repoList) => {
|
this.activitiContentService.getAlfrescoRepositories(null, true).subscribe((repoList) => {
|
||||||
this.repositoryList = repoList;
|
this.repositoryList = repoList;
|
||||||
@@ -229,8 +224,9 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.field.value = filesSaved;
|
const previousFiles = this.field.value;
|
||||||
this.field.json.value = filesSaved;
|
this.field.value = [ ...previousFiles, ...filesSaved ];
|
||||||
|
this.field.json.value = [ ...previousFiles, ...filesSaved ];
|
||||||
this.hasFile = true;
|
this.hasFile = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -80,6 +80,20 @@ const fakeMinimalNode: Node = <Node> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fakePngUpload = {
|
||||||
|
'id': 1166,
|
||||||
|
'name': 'fake-png.png',
|
||||||
|
'created': '2017-07-25T17:17:37.099Z',
|
||||||
|
'createdBy': {'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin'},
|
||||||
|
'relatedContent': false,
|
||||||
|
'contentAvailable': true,
|
||||||
|
'link': false,
|
||||||
|
'mimeType': 'image/png',
|
||||||
|
'simpleType': 'image',
|
||||||
|
'previewStatus': 'queued',
|
||||||
|
'thumbnailStatus': 'queued'
|
||||||
|
};
|
||||||
|
|
||||||
const fakePngAnswer = {
|
const fakePngAnswer = {
|
||||||
'id': 1155,
|
'id': 1155,
|
||||||
'name': 'a_png_file.png',
|
'name': 'a_png_file.png',
|
||||||
@@ -194,6 +208,38 @@ describe('AttachFileWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should be able to upload more than one file from content node selector', async(() => {
|
||||||
|
const clickAttachFile = () => {
|
||||||
|
const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach');
|
||||||
|
expect(attachButton).not.toBeNull();
|
||||||
|
attachButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
};
|
||||||
|
spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer));
|
||||||
|
spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValues(of(fakePngAnswer), of(fakePngUpload));
|
||||||
|
spyOn(contentNodeDialogService, 'openFileBrowseDialogBySite').and.returnValue(of([fakeMinimalNode]));
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
value: []
|
||||||
|
});
|
||||||
|
widget.field.id = 'attach-file-attach';
|
||||||
|
widget.field.params = <FormFieldMetadata> allSourceParams;
|
||||||
|
widget.field.params.multiple = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
clickAttachFile();
|
||||||
|
fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
clickAttachFile();
|
||||||
|
fixture.debugElement.query(By.css('#attach-GOKUSHARE')).nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(element.querySelector('#file-1155')).not.toBeNull();
|
||||||
|
expect(element.querySelector('#file-1166')).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should be able to upload files when a defined folder is selected', async(() => {
|
it('should be able to upload files when a defined folder is selected', async(() => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.UPLOAD,
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
Reference in New Issue
Block a user