Skip to content

Commit

Permalink
fix: expressions are properly included in getSchemaVariables
Browse files Browse the repository at this point in the history
Closes #1186
  • Loading branch information
Skaiir committed May 29, 2024
1 parent aaaaf35 commit 1e25516
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/form-js-viewer/src/util/getSchemaVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const EXPRESSION_PROPERTIES = [
'url',
'dataSource',
'columnsExpression',
'expression',
];

const TEMPLATE_PROPERTIES = [
Expand Down
18 changes: 18 additions & 0 deletions packages/form-js-viewer/test/spec/expressionField.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": "Form_1lywnv3",
"components": [
{
"computeOn": "change",
"label": "Expression",
"type": "expression",
"layout": {
"row": "Row_0duk8pr",
"columns": null
},
"id": "Field_01dikzb",
"key": "exp_expression",
"expression": "=flatten(data[selected = filter].dates)"
}
],
"type": "default"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import groupsSchema from '../groups.json';
import shipsExampleSchema from '../ships-example.json';
import iframesSchema from '../iframes.json';
import htmlSchema from '../html.json';
import expressionFieldSchema from '../expressionField.json';

describe('util/getSchemaVariables', () => {
it('should include form field keys', () => {
Expand Down Expand Up @@ -204,4 +205,10 @@ describe('util/getSchemaVariables', () => {
'separated2',
]);
});

it('should include variables in complex templates', () => {
const variables = getSchemaVariables(expressionFieldSchema);

expect(variables).to.include.members(['exp_expression', 'data', 'selected', 'filter']);
});
});

0 comments on commit 1e25516

Please sign in to comment.