mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Fix form visibility related to the process variables (#3232)
This commit is contained in:
committed by
Eugenio Romano
parent
95a2a54017
commit
1f72317e93
@@ -651,6 +651,76 @@ 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_TEST', res);
|
||||||
|
expect(varValue).not.toBeUndefined();
|
||||||
|
expect(varValue).toBe('process_variable_value');
|
||||||
|
|
||||||
|
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||||
|
visibilityObjTest.operator = '==';
|
||||||
|
visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE';
|
||||||
|
|
||||||
|
const fieldWithoutVisibility = <FormFieldModel> fakeFormWithField.getFieldById('FIELD_WITH_CONDITION');
|
||||||
|
fieldWithoutVisibility.isVisible = false;
|
||||||
|
fieldWithoutVisibility.visibilityCondition = visibilityObjTest;
|
||||||
|
|
||||||
|
let contModel = new ContainerModel(new FormFieldModel(fakeFormWithField));
|
||||||
|
|
||||||
|
fakeFormWithField.fields.push(contModel);
|
||||||
|
service.refreshVisibility(fakeFormWithField);
|
||||||
|
|
||||||
|
const fieldWithVisibilityAttached = contModel.form.getFieldById('FIELD_WITH_CONDITION');
|
||||||
|
expect(fieldWithVisibilityAttached.isVisible).toBeTruthy();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: [{id: 'FIELD_TEST', type: 'string', value: 'process_variable_value'}]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should use the process value to evaluate the visibility condition if the form value is not defined', (done) => {
|
||||||
|
|
||||||
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
|
(res: TaskProcessVariableModel[]) => {
|
||||||
|
expect(res).toBeDefined();
|
||||||
|
let varValue = service.getVariableValue(formTest, 'FIELD_TEST', res);
|
||||||
|
expect(varValue).not.toBeUndefined();
|
||||||
|
expect(varValue).toBe('process_variable_value');
|
||||||
|
|
||||||
|
visibilityObjTest.leftFormFieldId = 'FIELD_TEST';
|
||||||
|
visibilityObjTest.operator = '==';
|
||||||
|
visibilityObjTest.rightValue = 'RIGHT_FORM_FIELD_VALUE';
|
||||||
|
|
||||||
|
const fieldRelatedToCondition = <FormFieldModel> fakeFormWithField.getFieldById('FIELD_TEST');
|
||||||
|
fieldRelatedToCondition.value = '';
|
||||||
|
|
||||||
|
const fieldWithoutVisibility = <FormFieldModel> fakeFormWithField.getFieldById('FIELD_WITH_CONDITION');
|
||||||
|
fieldWithoutVisibility.isVisible = false;
|
||||||
|
fieldWithoutVisibility.visibilityCondition = visibilityObjTest;
|
||||||
|
|
||||||
|
let contModel = new ContainerModel(new FormFieldModel(fakeFormWithField));
|
||||||
|
|
||||||
|
fakeFormWithField.fields.push(contModel);
|
||||||
|
service.refreshVisibility(fakeFormWithField);
|
||||||
|
|
||||||
|
const fieldWithVisibilityAttached = contModel.form.getFieldById('FIELD_WITH_CONDITION');
|
||||||
|
expect(fieldWithVisibilityAttached.isVisible).toBeFalsy();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'json',
|
||||||
|
responseText: [{id: 'FIELD_TEST', type: 'string', value: 'process_variable_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 = '!=';
|
||||||
|
@@ -78,8 +78,8 @@ export class WidgetVisibilityService {
|
|||||||
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 {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user