diff --git a/demo-shell/package.json b/demo-shell/package.json index 11accd56fb..a55bbb295c 100644 --- a/demo-shell/package.json +++ b/demo-shell/package.json @@ -1,7 +1,7 @@ { "name": "Alfresco-ADF-Angular-Demo", "description": "Demo shell for Alfresco Angular components", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "scripts": { "ng": "ng", @@ -62,10 +62,10 @@ ], "private": true, "dependencies": { - "@alfresco/adf-content-services": "2.3.0", - "@alfresco/adf-core": "2.3.0", - "@alfresco/adf-insights": "2.3.0", - "@alfresco/adf-process-services": "2.3.0", + "@alfresco/adf-content-services": "2.3.1", + "@alfresco/adf-core": "2.3.1", + "@alfresco/adf-insights": "2.3.1", + "@alfresco/adf-process-services": "2.3.1", "@angular/animations": "5.1.1", "@angular/cdk": "5.0.1", "@angular/common": "5.1.1", @@ -81,7 +81,7 @@ "@mat-datetimepicker/core": "1.0.4", "@mat-datetimepicker/moment": "1.0.4", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", + "alfresco-js-api": "2.3.1", "chart.js": "2.5.0", "classlist.js": "1.1.20150312", "core-js": "2.4.1", diff --git a/lib/content-services/package.json b/lib/content-services/package.json index 96e0fab19b..9d87abf2cc 100644 --- a/lib/content-services/package.json +++ b/lib/content-services/package.json @@ -1,7 +1,7 @@ { "name": "@alfresco/adf-content-services", "description": "Alfresco ADF content services", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "main": "bundles/adf-content-services.js", "repository": { @@ -26,8 +26,8 @@ "@angular/platform-browser-dynamic": "5.1.1", "@angular/router": "5.1.1", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", - "@alfresco/adf-core": "2.3.0", + "alfresco-js-api": "2.3.1", + "@alfresco/adf-core": "2.3.1", "chart.js": "2.5.0", "core-js": "2.4.1", "hammerjs": "2.0.8", diff --git a/lib/core/form/services/widget-visibility.service.spec.ts b/lib/core/form/services/widget-visibility.service.spec.ts index 3f2c1fb158..33572904c2 100644 --- a/lib/core/form/services/widget-visibility.service.spec.ts +++ b/lib/core/form/services/widget-visibility.service.spec.ts @@ -348,6 +348,10 @@ describe('WidgetVisibilityService', () => { jsonFieldFake.visibilityCondition = visibilityObjTest; }); + afterEach( () => { + service.cleanProcessVariable(); + }); + it('should be able to retrieve a field value searching in the form', () => { let formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION'); @@ -641,6 +645,206 @@ describe('WidgetVisibilityService', () => { expect(fakeFormWithField.tabs[0].isVisible).toBeFalsy(); }); + it('should use the form value to evaluate the visibility condition if the form value is defined', (done) => { + service.getTaskProcessVariable('9999').subscribe( + (res: TaskProcessVariableModel[]) => { + expect(res).toBeDefined(); + let varValue = service.getVariableValue(formTest, 'FIELD_FORM_EMPTY', res); + expect(varValue).not.toBeUndefined(); + expect(varValue).toBe('PROCESS_RIGHT_FORM_FIELD_VALUE'); + + visibilityObjTest.leftFormFieldId = 'FIELD_FORM_EMPTY'; + visibilityObjTest.operator = '=='; + visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE'; + + let myForm = new FormModel({ + id: '9999', + name: 'FORM_PROCESS_VARIABLE_VISIBILITY', + processDefinitionId: 'PROCESS_TEST:9:9999', + processDefinitionName: 'PROCESS_TEST', + processDefinitionKey: 'PROCESS_TEST', + taskId: '999', + taskName: 'TEST', + fields: [ + { + fieldType: 'ContainerRepresentation', + id: '000000000000000000', + name: 'Label', + type: 'container', + value: null, + numberOfColumns: 2, + fields: { + 1: [ + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_EMPTY', + name: 'FIELD_FORM_EMPTY', + type: 'text', + value: 'RIGHT_FORM_FIELD_VALUE', + visibilityCondition: null, + isVisible: true + }, + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_WITH_CONDITION', + name: 'FIELD_FORM_WITH_CONDITION', + type: 'text', + value: 'field_form_with_condition_value', + visibilityCondition: visibilityObjTest, + isVisible: false + } + ] + } + } + ] + }); + + service.refreshVisibility(myForm); + + const fieldWithVisibilityAttached = myForm.getFieldById('FIELD_FORM_WITH_CONDITION'); + expect(fieldWithVisibilityAttached.isVisible).toBeTruthy(); + done(); + } + ); + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + contentType: 'json', + responseText: [{id: 'FIELD_FORM_EMPTY', type: 'string', value: 'PROCESS_RIGHT_FORM_FIELD_VALUE'}] + }); + }); + + it('should use the process value to evaluate the True visibility condition if the form value is empty', (done) => { + + service.getTaskProcessVariable('9999').subscribe( + (res: TaskProcessVariableModel[]) => { + expect(res).toBeDefined(); + + visibilityObjTest.leftFormFieldId = 'FIELD_FORM_EMPTY'; + visibilityObjTest.operator = '=='; + visibilityObjTest.rightValue = 'PROCESS_RIGHT_FORM_FIELD_VALUE'; + + let myForm = new FormModel({ + id: '9999', + name: 'FORM_PROCESS_VARIABLE_VISIBILITY', + processDefinitionId: 'PROCESS_TEST:9:9999', + processDefinitionName: 'PROCESS_TEST', + processDefinitionKey: 'PROCESS_TEST', + taskId: '999', + taskName: 'TEST', + fields: [ + { + fieldType: 'ContainerRepresentation', + id: '000000000000000000', + name: 'Label', + type: 'container', + value: null, + numberOfColumns: 2, + fields: { + 1: [ + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_EMPTY', + name: 'FIELD_FORM_EMPTY', + type: 'text', + value: '', + visibilityCondition: null, + isVisible: true + }, + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_WITH_CONDITION', + name: 'FIELD_FORM_WITH_CONDITION', + type: 'text', + value: 'field_form_with_condition_value', + visibilityCondition: visibilityObjTest, + isVisible: false + } + ] + } + } + ] + }); + + service.refreshVisibility(myForm); + + const fieldWithVisibilityAttached = myForm.getFieldById('FIELD_FORM_WITH_CONDITION'); + expect(fieldWithVisibilityAttached.isVisible).toBeTruthy(); + done(); + } + ); + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + contentType: 'json', + responseText: [{id: 'FIELD_FORM_EMPTY', type: 'string', value: 'PROCESS_RIGHT_FORM_FIELD_VALUE'}] + }); + }); + + it('should use the process value to evaluate the False visibility condition if the form value is empty', (done) => { + + service.getTaskProcessVariable('9999').subscribe( + (res: TaskProcessVariableModel[]) => { + expect(res).toBeDefined(); + + visibilityObjTest.leftFormFieldId = 'FIELD_FORM_EMPTY'; + visibilityObjTest.operator = '=='; + visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE'; + + let myForm = new FormModel({ + id: '9999', + name: 'FORM_PROCESS_VARIABLE_VISIBILITY', + processDefinitionId: 'PROCESS_TEST:9:9999', + processDefinitionName: 'PROCESS_TEST', + processDefinitionKey: 'PROCESS_TEST', + taskId: '999', + taskName: 'TEST', + fields: [ + { + fieldType: 'ContainerRepresentation', + id: '000000000000000000', + name: 'Label', + type: 'container', + value: null, + numberOfColumns: 2, + fields: { + 1: [ + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_EMPTY', + name: 'FIELD_FORM_EMPTY', + type: 'text', + value: '', + visibilityCondition: null, + isVisible: true + }, + { + fieldType: 'FormFieldRepresentation', + id: 'FIELD_FORM_WITH_CONDITION', + name: 'FIELD_FORM_WITH_CONDITION', + type: 'text', + value: 'field_form_with_condition_value', + visibilityCondition: visibilityObjTest, + isVisible: true + } + ] + } + } + ] + }); + + service.refreshVisibility(myForm); + + const fieldWithVisibilityAttached = myForm.getFieldById('FIELD_FORM_WITH_CONDITION'); + expect(fieldWithVisibilityAttached.isVisible).toBeFalsy(); + done(); + } + ); + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + contentType: 'json', + responseText: [{id: 'FIELD_FORM_EMPTY', type: 'string', value: 'PROCESS_RIGHT_FORM_FIELD_VALUE'}] + }); + }); + it('should refresh the visibility for single tab', () => { visibilityObjTest.leftFormFieldId = 'FIELD_TEST'; visibilityObjTest.operator = '!='; diff --git a/lib/core/form/services/widget-visibility.service.ts b/lib/core/form/services/widget-visibility.service.ts index a25441ab42..8bf36b1b0f 100644 --- a/lib/core/form/services/widget-visibility.service.ts +++ b/lib/core/form/services/widget-visibility.service.ts @@ -77,9 +77,9 @@ export class WidgetVisibilityService { let leftValue = ''; if (visibilityObj.leftRestResponseId && visibilityObj.leftRestResponseId !== 'null') { leftValue = this.getVariableValue(form, visibilityObj.leftRestResponseId, this.processVarList); - } else { - leftValue = this.getVariableValue(form, visibilityObj.leftFormFieldId, this.processVarList); - leftValue = leftValue ? leftValue : this.getFormValue(form, visibilityObj.leftFormFieldId); + } else if (visibilityObj.leftFormFieldId) { + leftValue = this.getFormValue(form, visibilityObj.leftFormFieldId); + leftValue = leftValue ? leftValue : this.getVariableValue(form, visibilityObj.leftFormFieldId, this.processVarList); } return leftValue; } diff --git a/lib/core/package.json b/lib/core/package.json index 99fd89e4c8..b27a72fe11 100644 --- a/lib/core/package.json +++ b/lib/core/package.json @@ -1,7 +1,7 @@ { "name": "@alfresco/adf-core", "description": "Alfresco ADF core", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "main": "bundles/adf-core.js", "repository": { @@ -26,7 +26,7 @@ "@angular/platform-browser-dynamic": "5.1.1", "@angular/router": "5.1.1", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", + "alfresco-js-api": "2.3.1", "chart.js": "2.5.0", "core-js": "2.4.1", "hammerjs": "2.0.8", diff --git a/lib/insights/package.json b/lib/insights/package.json index 09dcd58270..030b2590df 100644 --- a/lib/insights/package.json +++ b/lib/insights/package.json @@ -1,7 +1,7 @@ { "name": "@alfresco/adf-insights", "description": "Alfresco ADF insights", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "main": "bundles/adf-insights.js", "repository": { @@ -26,8 +26,8 @@ "@angular/platform-browser-dynamic": "5.1.1", "@angular/router": "5.1.1", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", - "@alfresco/adf-core": "2.3.0", + "alfresco-js-api": "2.3.1", + "@alfresco/adf-core": "2.3.1", "chart.js": "2.5.0", "core-js": "2.4.1", "hammerjs": "2.0.8", diff --git a/lib/package.json b/lib/package.json index 79a752e510..976fd18b62 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,7 +1,7 @@ { "name": "alfresco-components", "description": "Alfresco Angular components", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "scripts": { "clean": "rimraf node_modules", @@ -69,7 +69,7 @@ "@mat-datetimepicker/core": "1.0.4", "@mat-datetimepicker/moment": "1.0.4", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", + "alfresco-js-api": "2.3.1", "chart.js": "2.5.0", "core-js": "2.4.1", "graphql-request": "^1.5.1", diff --git a/lib/process-services/package.json b/lib/process-services/package.json index 60af46a5af..eec304698f 100644 --- a/lib/process-services/package.json +++ b/lib/process-services/package.json @@ -1,7 +1,7 @@ { "name": "@alfresco/adf-process-services", "description": "Alfresco ADF process services", - "version": "2.3.0", + "version": "2.3.1", "author": "Alfresco Software, Ltd.", "main": "bundles/adf-process-services.js", "repository": { @@ -12,8 +12,8 @@ "url": "https://github.com/Alfresco/alfresco-ng2-components/issues" }, "dependencies": { - "@alfresco/adf-core": "2.3.0", - "@alfresco/adf-content-services": "2.3.0", + "@alfresco/adf-core": "2.3.1", + "@alfresco/adf-content-services": "2.3.1", "@angular/animations": "5.1.1", "@angular/cdk": "5.0.1", "@angular/common": "5.1.1", @@ -28,7 +28,7 @@ "@angular/platform-browser-dynamic": "5.1.1", "@angular/router": "5.1.1", "@ngx-translate/core": "9.1.1", - "alfresco-js-api": "2.3.0", + "alfresco-js-api": "2.3.1", "chart.js": "2.5.0", "core-js": "2.4.1", "hammerjs": "2.0.8",