Skip to content

Commit

Permalink
FIO-7525: fixed an issue where new conditional logic based on select …
Browse files Browse the repository at this point in the history
…boxes does not work
  • Loading branch information
TanyaGashtold committed Nov 9, 2023
1 parent 38f4d53 commit 8790588
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 53 deletions.
32 changes: 32 additions & 0 deletions src/Webform.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,38 @@ describe('Webform tests', function() {
}, 300);
}).catch((err) => done(err));
});

it('Should show the field on select boxes value', function(done) {
const formElement = document.createElement('div');
const form = new Webform(formElement);

form.setForm(formsWithNewSimpleConditions.form6).then(() => {
const conditionalComponent = form.getComponent('textField');
const selectBoxes = form.getComponent('selectBoxes');
assert.equal(conditionalComponent.visible, false, '(1) Component should be conditionally hidden');

const selectBoxesValue = {
'111': true,
'222': false
};
selectBoxes.setValue(selectBoxesValue);

setTimeout(() => {
assert.deepEqual(selectBoxes.dataValue, selectBoxesValue, '(2) SelectBoxes value should be set');
assert.equal(conditionalComponent.visible, true, '(3) Component should be conditionally visible');

selectBoxes.setValue({
'111': false,
'222': false
});

setTimeout(() => {
assert.equal(conditionalComponent.visible, false, '(4) Component should be conditionally hidden');
done();
}, 300);
}, 300);
}).catch((err) => done(err));
});
});

describe('Calculate Value with allowed manual override', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/selectboxes/SelectBoxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class SelectBoxesComponent extends RadioComponent {
type: 'select',
dataSrc: 'custom',
valueProperty: 'value',
valueType: 'string',
dataType: 'string',
data: {
custom: `values = ${classComp && classComp.values ? JSON.stringify(classComp.values) : []}`
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/conditionOperators/IsEqualTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class IsEqualTo extends ConditionOperator {
}

//special check for select boxes
if (_.isObject(value) && comparedValue && _.isString(comparedValue)) {
if (_.isObject(value) && comparedValue && _.isBoolean(value[comparedValue])) {
return value[comparedValue];
}

Expand Down
Loading

0 comments on commit 8790588

Please sign in to comment.