diff --git a/lib/core/form/services/activiti-alfresco.service.ts b/lib/core/form/services/activiti-alfresco.service.ts index 8f497d4a2b..0688de70f3 100644 --- a/lib/core/form/services/activiti-alfresco.service.ts +++ b/lib/core/form/services/activiti-alfresco.service.ts @@ -102,7 +102,7 @@ export class ActivitiContentService { mimeType: node.content.mimeType, sourceId: node.id + ';' + node.properties['cm:versionLabel'] + '@' + currentSideId, name: node.name, - link: false + link: node.isLink }; return from(apiService.activiti.contentApi.createTemporaryRelatedContent(params)) .pipe( diff --git a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts index 2f3358c673..93d282fe15 100644 --- a/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts +++ b/lib/process-services/src/lib/content-widget/attach-file-widget.component.ts @@ -225,6 +225,11 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements private uploadFileFromCS(fileNodeList: any[], accountId: string, siteId?: string) { const filesSaved = []; + + fileNodeList.forEach(node => { + node.isLink = this.field.params.link; + }); + from(fileNodeList).pipe( mergeMap((node) => zip( diff --git a/lib/process-services/src/lib/content-widget/attach-file-widget.components.spec.ts b/lib/process-services/src/lib/content-widget/attach-file-widget.components.spec.ts index 4780c80a5f..fe30691b88 100644 --- a/lib/process-services/src/lib/content-widget/attach-file-widget.components.spec.ts +++ b/lib/process-services/src/lib/content-widget/attach-file-widget.components.spec.ts @@ -41,7 +41,8 @@ const fakeRepositoryListAnswer = [ 'serviceId': 'alfresco-9999-SHAREME', 'metaDataAllowed': true, 'name': 'SHAREME', - 'repositoryUrl': 'http://localhost:0000/SHAREME' + 'repositoryUrl': 'http://localhost:0000/SHAREME', + 'id': 1000 }, { 'authorized': true, @@ -60,7 +61,8 @@ const onlyLocalParams = { const allSourceParams = { fileSource: { serviceId: 'all-file-sources' - } + }, + link: false }; const allSourceParamsWithLinkEnabled = { @@ -231,6 +233,58 @@ describe('AttachFileWidgetComponent', () => { }); }); + it('should isLink property of the selected node become true when the widget has link enabled', async (done) => { + spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); + const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode'); + 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 = allSourceParamsWithLinkEnabled; + + fixture.detectChanges(); + await fixture.whenRenderingDone(); + + const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach'); + expect(attachButton).not.toBeNull(); + attachButton.click(); + + fixture.detectChanges(); + await fixture.whenStable(); + + fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click(); + expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: true }, undefined, 'alfresco-1000-SHAREME'); + done(); + }); + + it('should isLink property of the selected node become false when the widget has link disabled', async (done) => { + spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); + const applyAlfrescoNodeSpy = spyOn(activitiContentService, 'applyAlfrescoNode'); + 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 = allSourceParams; + + fixture.detectChanges(); + await fixture.whenRenderingDone(); + + const attachButton: HTMLButtonElement = element.querySelector('#attach-file-attach'); + expect(attachButton).not.toBeNull(); + attachButton.click(); + + fixture.detectChanges(); + await fixture.whenStable(); + + fixture.debugElement.query(By.css('#attach-SHAREME')).nativeElement.click(); + expect(applyAlfrescoNodeSpy).toHaveBeenCalledWith({ ...fakeMinimalNode, isLink: false }, undefined, 'alfresco-1000-SHAREME'); + done(); + }); + it('should be able to upload files coming from content node selector', async(() => { spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(fakeRepositoryListAnswer)); spyOn(activitiContentService, 'applyAlfrescoNode').and.returnValue(of(fakePngAnswer));