mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4848] Form - fix tab visibility (#5021)
* [ADF-4848] - fix tab visibility * add unit test
This commit is contained in:
committed by
Eugenio Romano
parent
2b1250cae7
commit
be867b0c0c
@@ -38,7 +38,7 @@ export class TabModel extends FormWidgetModel {
|
|||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
this.title = json.title;
|
this.title = json.title;
|
||||||
this.visibilityCondition = <WidgetVisibilityModel> json.visibilityCondition;
|
this.visibilityCondition = new WidgetVisibilityModel(json.visibilityCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
|||||||
import { fakeTaskProcessVariableModels,
|
import { fakeTaskProcessVariableModels,
|
||||||
fakeFormJson, formTest,
|
fakeFormJson, formTest,
|
||||||
formValues, complexVisibilityJsonVisible,
|
formValues, complexVisibilityJsonVisible,
|
||||||
complexVisibilityJsonNotVisible } from 'core/mock/form/widget-visibility.service.mock';
|
complexVisibilityJsonNotVisible, tabVisibilityJsonMock } from 'core/mock/form/widget-visibility.service.mock';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -929,6 +929,7 @@ describe('WidgetVisibilityService', () => {
|
|||||||
describe('Visibility based on form variables', () => {
|
describe('Visibility based on form variables', () => {
|
||||||
|
|
||||||
let fakeFormWithVariables = new FormModel(fakeFormJson);
|
let fakeFormWithVariables = new FormModel(fakeFormJson);
|
||||||
|
const fakeTabVisibilityModel = new FormModel(tabVisibilityJsonMock);
|
||||||
const complexVisibilityModel = new FormModel(complexVisibilityJsonVisible);
|
const complexVisibilityModel = new FormModel(complexVisibilityJsonVisible);
|
||||||
const complexVisibilityJsonNotVisibleModel = new FormModel(complexVisibilityJsonNotVisible);
|
const complexVisibilityJsonNotVisibleModel = new FormModel(complexVisibilityJsonNotVisible);
|
||||||
let visibilityObjTest: WidgetVisibilityModel;
|
let visibilityObjTest: WidgetVisibilityModel;
|
||||||
@@ -1014,5 +1015,18 @@ describe('WidgetVisibilityService', () => {
|
|||||||
expect(isVisible).toBeTruthy();
|
expect(isVisible).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should validate visiblity for multiple tabs', () => {
|
||||||
|
visibilityObjTest.leftFormFieldId = 'label';
|
||||||
|
visibilityObjTest.operator = '==';
|
||||||
|
visibilityObjTest.rightValue = 'text';
|
||||||
|
|
||||||
|
service.refreshVisibility(fakeTabVisibilityModel);
|
||||||
|
expect(fakeTabVisibilityModel.tabs[1].isVisible).toBeFalsy();
|
||||||
|
|
||||||
|
fakeTabVisibilityModel.getFieldById('label').value = 'text';
|
||||||
|
service.refreshVisibility(fakeTabVisibilityModel);
|
||||||
|
expect(fakeTabVisibilityModel.tabs[1].isVisible).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { FormModel, FormValues } from '../../form/components/widgets/core/index';
|
import { FormModel, FormValues } from '../../form/components/widgets/core/index';
|
||||||
|
|
||||||
export let formTest = new FormModel({});
|
export let formTest = new FormModel({});
|
||||||
@@ -857,3 +858,144 @@ export let complexVisibilityJsonNotVisible = {
|
|||||||
'gridsterForm': false
|
'gridsterForm': false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let tabVisibilityJsonMock = {
|
||||||
|
'id': 45231,
|
||||||
|
'name': 'visibility-form',
|
||||||
|
'description': '',
|
||||||
|
'version': 2,
|
||||||
|
'lastUpdatedBy': 4255,
|
||||||
|
'lastUpdatedByFullName': 'first last',
|
||||||
|
'lastUpdated': '2019-08-26T08: 04: 02.091+0000',
|
||||||
|
'stencilSetId': null,
|
||||||
|
'referenceId': null,
|
||||||
|
'tabs': [
|
||||||
|
{
|
||||||
|
'id': 'tab1',
|
||||||
|
'title': 'tab1',
|
||||||
|
'visibilityCondition': null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': 'tab2',
|
||||||
|
'title': 'Tab2',
|
||||||
|
'visibilityCondition': {
|
||||||
|
'leftFormFieldId': 'label',
|
||||||
|
'leftRestResponseId': null,
|
||||||
|
'operator': '==',
|
||||||
|
'rightValue': 'text',
|
||||||
|
'rightType': null,
|
||||||
|
'rightFormFieldId': '',
|
||||||
|
'rightRestResponseId': '',
|
||||||
|
'nextConditionOperator': '',
|
||||||
|
'nextCondition': null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'formDefinition': {
|
||||||
|
'fields': [
|
||||||
|
{
|
||||||
|
'fieldType': 'ContainerRepresentation',
|
||||||
|
'id': '1566806229182',
|
||||||
|
'name': 'Label',
|
||||||
|
'type': 'container',
|
||||||
|
'value': null,
|
||||||
|
'required': false,
|
||||||
|
'readOnly': false,
|
||||||
|
'overrideId': false,
|
||||||
|
'colspan': 1,
|
||||||
|
'placeholder': null,
|
||||||
|
'minLength': 0,
|
||||||
|
'maxLength': 0,
|
||||||
|
'minValue': null,
|
||||||
|
'maxValue': null,
|
||||||
|
'regexPattern': null,
|
||||||
|
'optionType': null,
|
||||||
|
'hasEmptyValue': null,
|
||||||
|
'options': null,
|
||||||
|
'restUrl': null,
|
||||||
|
'restResponsePath': null,
|
||||||
|
'restIdProperty': null,
|
||||||
|
'restLabelProperty': null,
|
||||||
|
'tab': 'tab1',
|
||||||
|
'className': null,
|
||||||
|
'dateDisplayFormat': null,
|
||||||
|
'layout': null,
|
||||||
|
'sizeX': 2,
|
||||||
|
'sizeY': 1,
|
||||||
|
'row': -1,
|
||||||
|
'col': -1,
|
||||||
|
'visibilityCondition': null,
|
||||||
|
'numberOfColumns': 2,
|
||||||
|
'fields': {
|
||||||
|
'1': [
|
||||||
|
{
|
||||||
|
'fieldType': 'FormFieldRepresentation',
|
||||||
|
'id': 'label',
|
||||||
|
'name': 'Label',
|
||||||
|
'type': 'text',
|
||||||
|
'value': null,
|
||||||
|
'required': false,
|
||||||
|
'readOnly': false,
|
||||||
|
'overrideId': false,
|
||||||
|
'colspan': 1,
|
||||||
|
'placeholder': null,
|
||||||
|
'minLength': 0,
|
||||||
|
'maxLength': 0,
|
||||||
|
'minValue': null,
|
||||||
|
'maxValue': null,
|
||||||
|
'regexPattern': null,
|
||||||
|
'optionType': null,
|
||||||
|
'hasEmptyValue': null,
|
||||||
|
'options': null,
|
||||||
|
'restUrl': null,
|
||||||
|
'restResponsePath': null,
|
||||||
|
'restIdProperty': null,
|
||||||
|
'restLabelProperty': null,
|
||||||
|
'tab': 'tab1',
|
||||||
|
'className': null,
|
||||||
|
'params': {
|
||||||
|
'existingColspan': 1,
|
||||||
|
'maxColspan': 2
|
||||||
|
},
|
||||||
|
'dateDisplayFormat': null,
|
||||||
|
'layout': {
|
||||||
|
'row': -1,
|
||||||
|
'column': -1,
|
||||||
|
'colspan': 1
|
||||||
|
},
|
||||||
|
'sizeX': 1,
|
||||||
|
'sizeY': 1,
|
||||||
|
'row': -1,
|
||||||
|
'col': -1,
|
||||||
|
'visibilityCondition': null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'2': [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'outcomes': [
|
||||||
|
|
||||||
|
],
|
||||||
|
'javascriptEvents': [
|
||||||
|
|
||||||
|
],
|
||||||
|
'className': '',
|
||||||
|
'style': '',
|
||||||
|
'customFieldTemplates': {
|
||||||
|
|
||||||
|
},
|
||||||
|
'metadata': {
|
||||||
|
|
||||||
|
},
|
||||||
|
'variables': [
|
||||||
|
|
||||||
|
],
|
||||||
|
'customFieldsValueInfo': {
|
||||||
|
|
||||||
|
},
|
||||||
|
'gridsterForm': false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user