From 16e19ca7c613566ef2891432f2d3a6aeb0568ba1 Mon Sep 17 00:00:00 2001 From: Sushmitha V <58967843+Sushmitha-Vk@users.noreply.github.com> Date: Mon, 1 Aug 2022 18:15:57 +0530 Subject: [PATCH] =?UTF-8?q?[AAE-8561]=20[Modeling]=20The=20'value'=20of=20?= =?UTF-8?q?string=20var=20in=20destinat=E2=80=A6=20(#7722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ci:force][AAE-8561] [Modeling] The 'value' of string var in destinationFolderPath is not always visible in JSON Editor * UPdated UT --- lib/core/form/components/widgets/core/form.model.ts | 2 +- .../attach-file-cloud-widget.component.spec.ts | 13 ++++--------- .../widgets/attach-file/upload-cloud.widget.ts | 2 +- .../lib/form/mocks/attach-file-cloud-widget.mock.ts | 5 +++-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/core/form/components/widgets/core/form.model.ts b/lib/core/form/components/widgets/core/form.model.ts index 7847a5f004..2c04731fc4 100644 --- a/lib/core/form/components/widgets/core/form.model.ts +++ b/lib/core/form/components/widgets/core/form.model.ts @@ -103,7 +103,7 @@ export class FormModel implements ProcessFormModel { this.customFieldTemplates = json.customFieldTemplates || {}; this.selectedOutcome = json.selectedOutcome; this.className = json.className || ''; - this.variables = json.variables || []; + this.variables = json.variables || json.formDefinition?.variables || []; this.processVariables = json.processVariables || []; this.enableFixedSpace = enableFixedSpace ? true : false; this.confirmMessage = json.confirmMessage || {}; diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts index 5c94784cab..aab6d22cdf 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.spec.ts @@ -302,7 +302,8 @@ describe('AttachFileCloudWidgetComponent', () => { it('should be able to use mapped string variable value if the destinationFolderPath set to string type variable', async () => { const getNodeIdFromPathSpy = spyOn(contentCloudNodeSelectorService, 'getNodeIdFromPath').and.returnValue(mockNodeIdBasedOnStringVariableValue); - const form = new FormModel({ formVariables, processVariables }); + const variables = formVariables; + const form = new FormModel({ variables, formVariables, processVariables }); createUploadWidgetField(form, 'attach-file-alfresco', [], mockAllFileSourceWithStringVariablePathType); fixture.detectChanges(); await fixture.whenStable(); @@ -787,8 +788,10 @@ describe('AttachFileCloudWidgetComponent', () => { describe('Upload widget with destination folder path params', () => { let form: FormModel; + const variables = formVariables; beforeEach(() => { form = new FormModel({ + variables, formVariables, processVariables }); @@ -810,14 +813,6 @@ describe('AttachFileCloudWidgetComponent', () => { expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('mock-folder-id'); }); - it('it should get a destination folder path value from a folder variable', () => { - createUploadWidgetField(form, 'attach-file-attach', [], mockAllFileSourceWithFolderVariablePathType); - fixture.detectChanges(); - - expect(widget.field.params.fileSource.destinationFolderPath.type).toBe('folder'); - expect(widget.field.params.fileSource.destinationFolderPath.value).toBe('mock-folder-id'); - }); - it('it should set destination folder path value to undefined if mapped variable deleted/renamed', () => { createUploadWidgetField(form, 'attach-file-attach', [], mockAllFileSourceWithRenamedFolderVariablePathType); fixture.detectChanges(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.ts index 6bfb5ba066..ab398bee4d 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/upload-cloud.widget.ts @@ -204,6 +204,6 @@ export class UploadCloudWidgetComponent extends WidgetComponent implements OnIni } private getDestinationFolderPathValue(): any { - return this.field.form.getProcessVariableValue(this.field.params.fileSource?.destinationFolderPath?.name); + return this.field.form.getFormVariableValue(this.field.params.fileSource?.destinationFolderPath?.name); } } diff --git a/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts b/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts index 1bba0a4eb7..77a36cbfd9 100644 --- a/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts +++ b/lib/process-services-cloud/src/lib/form/mocks/attach-file-cloud-widget.mock.ts @@ -397,12 +397,13 @@ export const formVariables = [ id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', name: 'name1', type: 'string', - value: 'hello' + value: '-root-/pathBasedOnStringvariablevalue' }, { id: '3ed9f28a-dbae-463f-b991-47ef06658bb6', name: 'name2', - type: 'folder' + type: 'folder', + value: [{ id: 'mock-folder-id'}] }, { id: 'booleanVar',