[AAE-612] Support for Form Outcome Visibility Conditions (#5934)

This commit is contained in:
davidcanonieto
2020-07-30 17:05:10 +01:00
committed by GitHub
parent 0afbe36787
commit 1e692252a5
8 changed files with 101 additions and 12 deletions

View File

@@ -23,11 +23,30 @@ describe('FormOutcomeModel', () => {
it('should setup with json config', () => {
const json = {
id: '<id>',
name: '<name>'
name: '<name>',
visibilityCondition: {
leftType: 'field',
leftValue: 'TextOne',
operator: '==',
rightValue: 'showTab',
rightType: 'value',
nextConditionOperator: '',
nextCondition: null
}
};
const model = new FormOutcomeModel(null, json);
expect(model.id).toBe(json.id);
expect(model.name).toBe(json.name);
expect(model.visibilityCondition).toBeDefined();
});
it('should not setup with null json config', () => {
const model = new FormOutcomeModel(null, null);
expect(model.id).toBeUndefined();
expect(model.name).toBeUndefined();
expect(model.isVisible).toBeDefined();
expect(model.isVisible).toBe(true);
expect(model.visibilityCondition).toBeUndefined();
});
it('should store the form reference', () => {

View File

@@ -19,6 +19,7 @@
import { FormWidgetModel } from './form-widget.model';
import { FormModel } from './form.model';
import { WidgetVisibilityModel } from './../../../models/widget-visibility.model';
export class FormOutcomeModel extends FormWidgetModel {
@@ -28,6 +29,8 @@ export class FormOutcomeModel extends FormWidgetModel {
isSystem: boolean = false;
isSelected: boolean = false;
isVisible: boolean = true;
visibilityCondition: WidgetVisibilityModel;
constructor(form: FormModel, json?: any) {
super(form, json);
@@ -35,6 +38,7 @@ export class FormOutcomeModel extends FormWidgetModel {
if (json) {
this.isSystem = json.isSystem ? true : false;
this.isSelected = form && json.name === form.selectedOutcome ? true : false;
this.visibilityCondition = new WidgetVisibilityModel(json.visibilityCondition);
}
}
}

View File

@@ -35,7 +35,7 @@ describe('TabModel', () => {
expect(model.isVisible).toBe(true);
});
it('should not setup with json config', () => {
it('should not setup with null json config', () => {
const model = new TabModel(null, null);
expect(model.id).toBeUndefined();
expect(model.title).toBeUndefined();