mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2825] - Form visibility fix on Master (#3237)
* Fix form visibility related to the process variables (#3232) * bump 2.3.1 version
This commit is contained in:
committed by
Eugenio Romano
parent
afa298060a
commit
c3db1c2ff8
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Alfresco-ADF-Angular-Demo",
|
"name": "Alfresco-ADF-Angular-Demo",
|
||||||
"description": "Demo shell for Alfresco Angular components",
|
"description": "Demo shell for Alfresco Angular components",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
@@ -62,10 +62,10 @@
|
|||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alfresco/adf-content-services": "2.3.0",
|
"@alfresco/adf-content-services": "2.3.1",
|
||||||
"@alfresco/adf-core": "2.3.0",
|
"@alfresco/adf-core": "2.3.1",
|
||||||
"@alfresco/adf-insights": "2.3.0",
|
"@alfresco/adf-insights": "2.3.1",
|
||||||
"@alfresco/adf-process-services": "2.3.0",
|
"@alfresco/adf-process-services": "2.3.1",
|
||||||
"@angular/animations": "5.1.1",
|
"@angular/animations": "5.1.1",
|
||||||
"@angular/cdk": "5.0.1",
|
"@angular/cdk": "5.0.1",
|
||||||
"@angular/common": "5.1.1",
|
"@angular/common": "5.1.1",
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
"@mat-datetimepicker/core": "1.0.4",
|
"@mat-datetimepicker/core": "1.0.4",
|
||||||
"@mat-datetimepicker/moment": "1.0.4",
|
"@mat-datetimepicker/moment": "1.0.4",
|
||||||
"@ngx-translate/core": "9.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",
|
"chart.js": "2.5.0",
|
||||||
"classlist.js": "1.1.20150312",
|
"classlist.js": "1.1.20150312",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@alfresco/adf-content-services",
|
"name": "@alfresco/adf-content-services",
|
||||||
"description": "Alfresco ADF content services",
|
"description": "Alfresco ADF content services",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"main": "bundles/adf-content-services.js",
|
"main": "bundles/adf-content-services.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
"@angular/platform-browser-dynamic": "5.1.1",
|
"@angular/platform-browser-dynamic": "5.1.1",
|
||||||
"@angular/router": "5.1.1",
|
"@angular/router": "5.1.1",
|
||||||
"@ngx-translate/core": "9.1.1",
|
"@ngx-translate/core": "9.1.1",
|
||||||
"alfresco-js-api": "2.3.0",
|
"alfresco-js-api": "2.3.1",
|
||||||
"@alfresco/adf-core": "2.3.0",
|
"@alfresco/adf-core": "2.3.1",
|
||||||
"chart.js": "2.5.0",
|
"chart.js": "2.5.0",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
@@ -348,6 +348,10 @@ describe('WidgetVisibilityService', () => {
|
|||||||
jsonFieldFake.visibilityCondition = visibilityObjTest;
|
jsonFieldFake.visibilityCondition = visibilityObjTest;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach( () => {
|
||||||
|
service.cleanProcessVariable();
|
||||||
|
});
|
||||||
|
|
||||||
it('should be able to retrieve a field value searching in the form', () => {
|
it('should be able to retrieve a field value searching in the form', () => {
|
||||||
let formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
let formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||||
|
|
||||||
@@ -641,6 +645,206 @@ describe('WidgetVisibilityService', () => {
|
|||||||
expect(fakeFormWithField.tabs[0].isVisible).toBeFalsy();
|
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', () => {
|
it('should refresh the visibility for single tab', () => {
|
||||||
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||||
visibilityObjTest.operator = '!=';
|
visibilityObjTest.operator = '!=';
|
||||||
|
@@ -77,9 +77,9 @@ export class WidgetVisibilityService {
|
|||||||
let leftValue = '';
|
let leftValue = '';
|
||||||
if (visibilityObj.leftRestResponseId && visibilityObj.leftRestResponseId !== 'null') {
|
if (visibilityObj.leftRestResponseId && visibilityObj.leftRestResponseId !== 'null') {
|
||||||
leftValue = this.getVariableValue(form, visibilityObj.leftRestResponseId, this.processVarList);
|
leftValue = this.getVariableValue(form, visibilityObj.leftRestResponseId, this.processVarList);
|
||||||
} else {
|
} else if (visibilityObj.leftFormFieldId) {
|
||||||
leftValue = this.getVariableValue(form, visibilityObj.leftFormFieldId, this.processVarList);
|
leftValue = this.getFormValue(form, visibilityObj.leftFormFieldId);
|
||||||
leftValue = leftValue ? leftValue : this.getFormValue(form, visibilityObj.leftFormFieldId);
|
leftValue = leftValue ? leftValue : this.getVariableValue(form, visibilityObj.leftFormFieldId, this.processVarList);
|
||||||
}
|
}
|
||||||
return leftValue;
|
return leftValue;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@alfresco/adf-core",
|
"name": "@alfresco/adf-core",
|
||||||
"description": "Alfresco ADF core",
|
"description": "Alfresco ADF core",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"main": "bundles/adf-core.js",
|
"main": "bundles/adf-core.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"@angular/platform-browser-dynamic": "5.1.1",
|
"@angular/platform-browser-dynamic": "5.1.1",
|
||||||
"@angular/router": "5.1.1",
|
"@angular/router": "5.1.1",
|
||||||
"@ngx-translate/core": "9.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",
|
"chart.js": "2.5.0",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@alfresco/adf-insights",
|
"name": "@alfresco/adf-insights",
|
||||||
"description": "Alfresco ADF insights",
|
"description": "Alfresco ADF insights",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"main": "bundles/adf-insights.js",
|
"main": "bundles/adf-insights.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
"@angular/platform-browser-dynamic": "5.1.1",
|
"@angular/platform-browser-dynamic": "5.1.1",
|
||||||
"@angular/router": "5.1.1",
|
"@angular/router": "5.1.1",
|
||||||
"@ngx-translate/core": "9.1.1",
|
"@ngx-translate/core": "9.1.1",
|
||||||
"alfresco-js-api": "2.3.0",
|
"alfresco-js-api": "2.3.1",
|
||||||
"@alfresco/adf-core": "2.3.0",
|
"@alfresco/adf-core": "2.3.1",
|
||||||
"chart.js": "2.5.0",
|
"chart.js": "2.5.0",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "alfresco-components",
|
"name": "alfresco-components",
|
||||||
"description": "Alfresco Angular components",
|
"description": "Alfresco Angular components",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf node_modules",
|
"clean": "rimraf node_modules",
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"@mat-datetimepicker/core": "1.0.4",
|
"@mat-datetimepicker/core": "1.0.4",
|
||||||
"@mat-datetimepicker/moment": "1.0.4",
|
"@mat-datetimepicker/moment": "1.0.4",
|
||||||
"@ngx-translate/core": "9.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",
|
"chart.js": "2.5.0",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"graphql-request": "^1.5.1",
|
"graphql-request": "^1.5.1",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@alfresco/adf-process-services",
|
"name": "@alfresco/adf-process-services",
|
||||||
"description": "Alfresco ADF process services",
|
"description": "Alfresco ADF process services",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"author": "Alfresco Software, Ltd.",
|
"author": "Alfresco Software, Ltd.",
|
||||||
"main": "bundles/adf-process-services.js",
|
"main": "bundles/adf-process-services.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
|
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alfresco/adf-core": "2.3.0",
|
"@alfresco/adf-core": "2.3.1",
|
||||||
"@alfresco/adf-content-services": "2.3.0",
|
"@alfresco/adf-content-services": "2.3.1",
|
||||||
"@angular/animations": "5.1.1",
|
"@angular/animations": "5.1.1",
|
||||||
"@angular/cdk": "5.0.1",
|
"@angular/cdk": "5.0.1",
|
||||||
"@angular/common": "5.1.1",
|
"@angular/common": "5.1.1",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"@angular/platform-browser-dynamic": "5.1.1",
|
"@angular/platform-browser-dynamic": "5.1.1",
|
||||||
"@angular/router": "5.1.1",
|
"@angular/router": "5.1.1",
|
||||||
"@ngx-translate/core": "9.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",
|
"chart.js": "2.5.0",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
Reference in New Issue
Block a user