mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4787] Invalid value of number field is parsed and fields with visibility conditions based on the number field are visible (#5255)
* add another field visibility condition * * Fixed failing unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
173a160ee9
commit
7ca2f5d1e9
@@ -270,6 +270,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
service.getTaskProcessVariable('9999').subscribe(
|
service.getTaskProcessVariable('9999').subscribe(
|
||||||
() => {
|
() => {
|
||||||
visibilityObjTest.rightValue = 'test_value_2';
|
visibilityObjTest.rightValue = 'test_value_2';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).not.toBeNull();
|
expect(rightValue).not.toBeNull();
|
||||||
@@ -389,14 +390,16 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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', () => {
|
||||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||||
|
const formValue = service.searchValueInForm(formField, 'FIELD_WITH_CONDITION');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
expect(formValue).toBe('field_with_condition_value');
|
expect(formValue).toBe('field_with_condition_value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty string if the field value is not in the form', () => {
|
it('should return empty string if the field value is not in the form', () => {
|
||||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_MYSTERY');
|
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_MYSTERY');
|
||||||
|
const formValue = service.searchValueInForm(formField, 'FIELD_MYSTERY');
|
||||||
|
|
||||||
expect(formValue).not.toBeUndefined();
|
expect(formValue).not.toBeUndefined();
|
||||||
expect(formValue).toEqual('');
|
expect(formValue).toEqual('');
|
||||||
@@ -409,15 +412,14 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
expect(value).toBe('field_with_condition_value');
|
expect(value).toBe('field_with_condition_value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty string if the element is not present anywhere', () => {
|
it('should return undefined if the element is not present anywhere', () => {
|
||||||
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||||
|
expect(formValue).toBeUndefined();
|
||||||
expect(formValue).not.toBeUndefined();
|
|
||||||
expect(formValue).toEqual('');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should retrieve the value for the right field when it is a value', () => {
|
it('should retrieve the value for the right field when it is a value', () => {
|
||||||
visibilityObjTest.rightValue = '100';
|
visibilityObjTest.rightValue = '100';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBe('100');
|
expect(rightValue).toBe('100');
|
||||||
@@ -425,6 +427,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
|
|
||||||
it('should return formatted date when right value is a date', () => {
|
it('should return formatted date when right value is a date', () => {
|
||||||
visibilityObjTest.rightValue = '9999-12-31';
|
visibilityObjTest.rightValue = '9999-12-31';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
||||||
@@ -432,6 +435,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
|
|
||||||
it('should return the value when right value is not a date', () => {
|
it('should return the value when right value is not a date', () => {
|
||||||
visibilityObjTest.rightValue = '9999-99-99';
|
visibilityObjTest.rightValue = '9999-99-99';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBe('9999-99-99');
|
expect(rightValue).toBe('9999-99-99');
|
||||||
@@ -447,6 +451,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should take the value from form values if it is present', () => {
|
it('should take the value from form values if it is present', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const formValue = service.getFormValue(formTest, 'test_1');
|
const formValue = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
@@ -456,6 +461,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
it('should retrieve right value from form values if it is present', () => {
|
it('should retrieve right value from form values if it is present', () => {
|
||||||
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
||||||
visibilityObjTest.rightValue = 'test_2';
|
visibilityObjTest.rightValue = 'test_2';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).not.toBeNull();
|
expect(rightValue).not.toBeNull();
|
||||||
@@ -475,6 +481,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
it('should retrieve left value from form values if it is present', () => {
|
it('should retrieve left value from form values if it is present', () => {
|
||||||
visibilityObjTest.leftType = WidgetTypeEnum.field;
|
visibilityObjTest.leftType = WidgetTypeEnum.field;
|
||||||
visibilityObjTest.leftValue = 'test_2';
|
visibilityObjTest.leftValue = 'test_2';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(leftValue).not.toBeNull();
|
expect(leftValue).not.toBeNull();
|
||||||
@@ -492,6 +499,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
visibilityObjTest.rightType = WidgetTypeEnum.field;
|
||||||
visibilityObjTest.rightValue = 'test_3';
|
visibilityObjTest.rightValue = 'test_3';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
@@ -502,6 +510,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
visibilityObjTest.leftValue = 'test_1';
|
visibilityObjTest.leftValue = 'test_1';
|
||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightValue = 'value_1';
|
visibilityObjTest.rightValue = 'value_1';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
@@ -592,6 +601,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the dropdown id value from a form', () => {
|
it('should get the dropdown id value from a form', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
@@ -602,6 +612,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
||||||
visibilityObjTest.rightType = 'field';
|
visibilityObjTest.rightType = 'field';
|
||||||
visibilityObjTest.rightValue = 'dropdown';
|
visibilityObjTest.rightValue = 'dropdown';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBeDefined();
|
expect(rightValue).toBeDefined();
|
||||||
@@ -621,6 +632,7 @@ describe('WidgetVisibilityCloudService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get value from form values', () => {
|
it('should be able to get value from form values', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const res = service.getFormValue(formTest, 'test_1');
|
const res = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
|
@@ -373,14 +373,16 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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', () => {
|
||||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_WITH_CONDITION');
|
||||||
|
const formValue = service.searchValueInForm(formField, 'FIELD_WITH_CONDITION');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
expect(formValue).toBe('field_with_condition_value');
|
expect(formValue).toBe('field_with_condition_value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty string if the field value is not in the form', () => {
|
it('should return empty string if the field value is not in the form', () => {
|
||||||
const formValue = service.searchValueInForm(stubFormWithFields, 'FIELD_MYSTERY');
|
const formField = service.getFormFieldById(stubFormWithFields, 'FIELD_MYSTERY');
|
||||||
|
const formValue = service.searchValueInForm(formField, 'FIELD_MYSTERY');
|
||||||
|
|
||||||
expect(formValue).not.toBeUndefined();
|
expect(formValue).not.toBeUndefined();
|
||||||
expect(formValue).toBe('');
|
expect(formValue).toBe('');
|
||||||
@@ -395,13 +397,12 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should return empty string if the element is not present anywhere', () => {
|
it('should return empty string if the element is not present anywhere', () => {
|
||||||
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
const formValue = service.getFormValue(fakeFormWithField, 'FIELD_MYSTERY');
|
||||||
|
expect(formValue).toBeUndefined();
|
||||||
expect(formValue).not.toBeUndefined();
|
|
||||||
expect(formValue).toBe('');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should retrieve the value for the right field when it is a value', () => {
|
it('should retrieve the value for the right field when it is a value', () => {
|
||||||
visibilityObjTest.rightValue = '100';
|
visibilityObjTest.rightValue = '100';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBe('100');
|
expect(rightValue).toBe('100');
|
||||||
@@ -409,6 +410,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should return formatted date when right value is a date', () => {
|
it('should return formatted date when right value is a date', () => {
|
||||||
visibilityObjTest.rightValue = '9999-12-31';
|
visibilityObjTest.rightValue = '9999-12-31';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
expect(rightValue).toBe('9999-12-31T00:00:00.000Z');
|
||||||
@@ -430,6 +432,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should take the value from form values if it is present', () => {
|
it('should take the value from form values if it is present', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const formValue = service.getFormValue(formTest, 'test_1');
|
const formValue = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(formValue).not.toBeNull();
|
expect(formValue).not.toBeNull();
|
||||||
@@ -438,6 +441,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should retrieve right value from form values if it is present', () => {
|
it('should retrieve right value from form values if it is present', () => {
|
||||||
visibilityObjTest.rightFormFieldId = 'test_2';
|
visibilityObjTest.rightFormFieldId = 'test_2';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).not.toBeNull();
|
expect(rightValue).not.toBeNull();
|
||||||
@@ -455,6 +459,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should retrieve left value from form values if it is present', () => {
|
it('should retrieve left value from form values if it is present', () => {
|
||||||
visibilityObjTest.leftFormFieldId = 'test_2';
|
visibilityObjTest.leftFormFieldId = 'test_2';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
const leftValue = service.getLeftValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(leftValue).not.toBeNull();
|
expect(leftValue).not.toBeNull();
|
||||||
@@ -471,6 +476,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightFormFieldId = 'test_3';
|
visibilityObjTest.rightFormFieldId = 'test_3';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
@@ -480,17 +486,17 @@ describe('WidgetVisibilityService', () => {
|
|||||||
visibilityObjTest.leftFormFieldId = 'test_1';
|
visibilityObjTest.leftFormFieldId = 'test_1';
|
||||||
visibilityObjTest.operator = '==';
|
visibilityObjTest.operator = '==';
|
||||||
visibilityObjTest.rightValue = 'value_1';
|
visibilityObjTest.rightValue = 'value_1';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
const isVisible = service.isFieldVisible(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return empty string for a value that is not on variable or form', () => {
|
it('should undefined string for a value that is not on variable or form', () => {
|
||||||
visibilityObjTest.rightFormFieldId = 'NO_FIELD_FORM';
|
visibilityObjTest.rightFormFieldId = 'NO_FIELD_FORM';
|
||||||
const rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
const rightValue = service.getRightValue(fakeFormWithField, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).not.toBeUndefined();
|
expect(rightValue).toBeUndefined();
|
||||||
expect(rightValue).toBe('');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate the visibility for the field with single visibility condition between form values', () => {
|
it('should evaluate the visibility for the field with single visibility condition between form values', () => {
|
||||||
@@ -576,6 +582,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the dropdown label value from a form', () => {
|
it('should get the dropdown label value from a form', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const dropdownValue = service.getFormValue(formTest, 'dropdown_LABEL');
|
const dropdownValue = service.getFormValue(formTest, 'dropdown_LABEL');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
@@ -584,6 +591,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should get the dropdown id value from a form', () => {
|
it('should get the dropdown id value from a form', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
const dropdownValue = service.getFormValue(formTest, 'dropdown');
|
||||||
|
|
||||||
expect(dropdownValue).not.toBeNull();
|
expect(dropdownValue).not.toBeNull();
|
||||||
@@ -593,6 +601,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
it('should retrieve the value for the right field when it is a dropdown id', () => {
|
||||||
visibilityObjTest.rightFormFieldId = 'dropdown';
|
visibilityObjTest.rightFormFieldId = 'dropdown';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBeDefined();
|
expect(rightValue).toBeDefined();
|
||||||
@@ -601,6 +610,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
|
|
||||||
it('should retrieve the value for the right field when it is a dropdown label', () => {
|
it('should retrieve the value for the right field when it is a dropdown label', () => {
|
||||||
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
visibilityObjTest.rightFormFieldId = 'dropdown_LABEL';
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
const rightValue = service.getRightValue(formTest, visibilityObjTest);
|
||||||
|
|
||||||
expect(rightValue).toBeDefined();
|
expect(rightValue).toBeDefined();
|
||||||
@@ -628,6 +638,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to get value from form values', () => {
|
it('should be able to get value from form values', () => {
|
||||||
|
spyOn(service, 'isFormFieldValid').and.returnValue(true);
|
||||||
const res = service.getFormValue(formTest, 'test_1');
|
const res = service.getFormValue(formTest, 'test_1');
|
||||||
|
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
|
@@ -122,14 +122,23 @@ export class WidgetVisibilityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFormValue(form: FormModel, fieldId: string): any {
|
getFormValue(form: FormModel, fieldId: string): any {
|
||||||
let value = this.getFieldValue(form.values, fieldId);
|
const formField = this.getFormFieldById(form, fieldId);
|
||||||
|
let value = undefined;
|
||||||
|
|
||||||
if (this.isInvalidValue(value)) {
|
if (this.isFormFieldValid(formField)) {
|
||||||
value = this.searchValueInForm(form, fieldId);
|
value = this.getFieldValue(form.values, fieldId);
|
||||||
|
|
||||||
|
if (this.isInvalidValue(value)) {
|
||||||
|
value = this.searchValueInForm(formField, fieldId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFormFieldValid(formField: FormFieldModel): boolean {
|
||||||
|
return formField && formField.isValid;
|
||||||
|
}
|
||||||
|
|
||||||
getFieldValue(valueList: any, fieldId: string): any {
|
getFieldValue(valueList: any, fieldId: string): any {
|
||||||
let dropDownFilterByName, valueFound;
|
let dropDownFilterByName, valueFound;
|
||||||
if (fieldId && fieldId.indexOf('_LABEL') > 0) {
|
if (fieldId && fieldId.indexOf('_LABEL') > 0) {
|
||||||
@@ -149,20 +158,25 @@ export class WidgetVisibilityService {
|
|||||||
return value === undefined || value === null;
|
return value === undefined || value === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchValueInForm(form: FormModel, fieldId: string): string {
|
getFormFieldById(form: FormModel, fieldId: string): FormFieldModel {
|
||||||
|
return form.getFormFields().
|
||||||
|
find( (formField: FormFieldModel) => this.isSearchedField(formField, fieldId));
|
||||||
|
}
|
||||||
|
|
||||||
|
searchValueInForm(formField: FormFieldModel, fieldId: string): string {
|
||||||
let fieldValue = '';
|
let fieldValue = '';
|
||||||
form.getFormFields().forEach((formField: FormFieldModel) => {
|
|
||||||
if (this.isSearchedField(formField, fieldId)) {
|
if (formField) {
|
||||||
fieldValue = this.getObjectValue(formField, fieldId);
|
fieldValue = this.getObjectValue(formField, fieldId);
|
||||||
if (!fieldValue) {
|
|
||||||
if (formField.value && formField.value.id) {
|
if (!fieldValue) {
|
||||||
fieldValue = formField.value.id;
|
if (formField.value && formField.value.id) {
|
||||||
} else if (!this.isInvalidValue(formField.value)) {
|
fieldValue = formField.value.id;
|
||||||
fieldValue = formField.value;
|
} else if (!this.isInvalidValue(formField.value)) {
|
||||||
}
|
fieldValue = formField.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return fieldValue;
|
return fieldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user