From a238442d93544ae68b574f2a26789bb5768304ee Mon Sep 17 00:00:00 2001 From: MichalKinas <113341662+MichalKinas@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:51:17 +0200 Subject: [PATCH] [ACS-8635] Properly handle each case of viewing files linked to process/task (#10169) * [ACS-8635] Properly handle each case of viewing files linked to process/task * [ACS-8635] Unit test coverage --- .../attach-file-widget.component.spec.ts | 23 ++++++++----------- .../attach-file-widget.component.ts | 6 ++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts index da9e177eba..00ff85caf2 100644 --- a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts +++ b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts @@ -172,6 +172,16 @@ describe('AttachFileWidgetComponent', () => { fixture.destroy(); }); + it('should add file to tempFilesList when form has value and file source is configured', () => { + spyOn(widget, 'isFileSourceConfigured').and.returnValue(true); + widget.field = new FormFieldModel(new FormModel(), { + type: FormFieldTypes.UPLOAD, + value: [fakePngAnswer] + }); + fixture.detectChanges(); + expect(widget.isTemporaryFile(fakePngAnswer)).toBeTrue(); + }); + it('should show up as simple upload when is configured for only local files', async () => { spyOn(activitiContentService, 'getAlfrescoRepositories').and.returnValue(of(null)); widget.field = new FormFieldModel(new FormModel(), { @@ -517,19 +527,6 @@ describe('AttachFileWidgetComponent', () => { await fixture.whenStable(); }); - it('should raise formContentClicked event when file has sourceId', async () => { - const testFile = { - sourceId: '12345', - id: '12345', - contentAvailable: true - }; - formService.formContentClicked.subscribe((file) => { - expect(file).not.toBeNull(); - expect(file).toBe(testFile); - }); - fixture.componentInstance.onAttachFileClicked(testFile); - }); - it('should not display the show button file when is an external file', async () => { fakePngAnswer.isExternal = true; spyOn(processContentService, 'getFileRawContent').and.returnValue(of(fakePngAnswer)); diff --git a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts index 26bbb71146..6402bce5b1 100644 --- a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts +++ b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts @@ -85,6 +85,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements ngOnInit() { super.ngOnInit(); + if (Array.isArray(this.field.value) && this.isFileSourceConfigured()) { + this.tempFilesList.push(...this.field.value); + } + this.activitiContentService.getAlfrescoRepositories().subscribe((repoList) => { this.repositoryList = repoList; }); @@ -170,7 +174,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements if (file.isExternal || !file.contentAvailable) { return; } - if (this.isTemporaryFile(file) || file.sourceId) { + if (this.isTemporaryFile(file)) { this.formService.formContentClicked.next(file); } else { this.fileClicked(file);