From 739343c6602806600aaca67656b323f93b033c05 Mon Sep 17 00:00:00 2001 From: Vinicius Goulart Date: Mon, 28 Oct 2024 19:25:32 +0100 Subject: [PATCH] fix: make `getSchemaVariables` include filepicker property variables --- .../src/util/getSchemaVariables.js | 2 + .../form-js-viewer/test/spec/filepicker.json | 52 +++++++++++++++++++ .../test/spec/util/GetSchemaVariables.spec.js | 17 ++++++ 3 files changed, 71 insertions(+) create mode 100644 packages/form-js-viewer/test/spec/filepicker.json diff --git a/packages/form-js-viewer/src/util/getSchemaVariables.js b/packages/form-js-viewer/src/util/getSchemaVariables.js index d5615ce85..70c838bf8 100644 --- a/packages/form-js-viewer/src/util/getSchemaVariables.js +++ b/packages/form-js-viewer/src/util/getSchemaVariables.js @@ -23,6 +23,8 @@ const EXPRESSION_PROPERTIES = [ 'dataSource', 'columnsExpression', 'expression', + 'multiple', + 'accept', ]; const TEMPLATE_PROPERTIES = [ diff --git a/packages/form-js-viewer/test/spec/filepicker.json b/packages/form-js-viewer/test/spec/filepicker.json new file mode 100644 index 000000000..a0acf0b55 --- /dev/null +++ b/packages/form-js-viewer/test/spec/filepicker.json @@ -0,0 +1,52 @@ +{ + "components": [ + { + "label": "Root filepicker", + "type": "filepicker", + "id": "Field_0ix8ssu", + "key": "root_filepicker", + "accept": "=root_formats", + "multiple": "=root_multiple" + }, + { + "label": "", + "components": [ + { + "label": "Group filepicker", + "type": "filepicker", + "id": "Field_1afqrsw", + "key": "group_filepicker", + "accept": "=group_formats", + "multiple": "=group_multiple" + } + ], + "showOutline": true, + "type": "group", + "id": "Field_1r2phwv", + "path": "group_path" + }, + { + "label": "", + "components": [ + { + "label": "List filepicker", + "type": "filepicker", + "id": "Field_0ngzqh9", + "key": "list_filepicker", + "accept": "=list_formats", + "multiple": "=list_multiple" + } + ], + "showOutline": true, + "isRepeating": true, + "allowAddRemove": true, + "defaultRepetitions": 1, + "type": "dynamiclist", + "id": "Field_1mfpipo", + "path": "dynamiclist_path" + } + ], + "type": "default", + "id": "filepicker_form", + "schemaVersion": 17 +} diff --git a/packages/form-js-viewer/test/spec/util/GetSchemaVariables.spec.js b/packages/form-js-viewer/test/spec/util/GetSchemaVariables.spec.js index 590d90a38..2efbe6a2f 100644 --- a/packages/form-js-viewer/test/spec/util/GetSchemaVariables.spec.js +++ b/packages/form-js-viewer/test/spec/util/GetSchemaVariables.spec.js @@ -19,6 +19,7 @@ import shipsExampleSchema from '../ships-example.json'; import iframesSchema from '../iframes.json'; import htmlSchema from '../html.json'; import expressionFieldSchema from '../expressionField.json'; +import filepickerSchema from '../filepicker.json'; describe('util/getSchemaVariables', () => { it('should include form field keys', () => { @@ -211,4 +212,20 @@ describe('util/getSchemaVariables', () => { expect(variables).to.include.members(['exp_expression', 'data', 'selected', 'filter']); }); + + it('should include variables in filepickers', () => { + const variables = getSchemaVariables(filepickerSchema); + + expect(variables).to.eql([ + 'root_multiple', + 'root_formats', + 'group_multiple', + 'group_formats', + 'list_multiple', + 'list_formats', + 'root_filepicker', + 'group_path', + 'dynamiclist_path', + ]); + }); });