diff --git a/package-lock.json b/package-lock.json index 0e1fc40c..eff24157 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1601,6 +1601,11 @@ "preact": "^10.11.2" } }, + "node_modules/@bpmn-io/dmn-variable-resolver": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@bpmn-io/dmn-variable-resolver/-/dmn-variable-resolver-0.3.0.tgz", + "integrity": "sha512-1n3Z9zp69JFXT8DALR+eIvpyA8CB2pU6az/yPGH4lUqHFDFsyvVI5uVbLsMs4ztGZInLrW31b7KpKnfo3ItV8A==" + }, "node_modules/@bpmn-io/feel-editor": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@bpmn-io/feel-editor/-/feel-editor-0.9.1.tgz", @@ -19779,6 +19784,7 @@ "version": "14.4.1", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "css.escape": "^1.5.1", "diagram-js": "^12.0.0", "dmn-js-shared": "^14.4.1", @@ -19815,6 +19821,7 @@ "version": "14.4.3", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "diagram-js": "^12.0.0", "dmn-js-shared": "^14.4.1", "escape-html": "^1.0.3", @@ -20911,6 +20918,11 @@ "preact": "^10.11.2" } }, + "@bpmn-io/dmn-variable-resolver": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@bpmn-io/dmn-variable-resolver/-/dmn-variable-resolver-0.3.0.tgz", + "integrity": "sha512-1n3Z9zp69JFXT8DALR+eIvpyA8CB2pU6az/yPGH4lUqHFDFsyvVI5uVbLsMs4ztGZInLrW31b7KpKnfo3ItV8A==" + }, "@bpmn-io/feel-editor": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@bpmn-io/feel-editor/-/feel-editor-0.9.1.tgz", @@ -24822,6 +24834,7 @@ "dmn-js-decision-table": { "version": "file:packages/dmn-js-decision-table", "requires": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "css.escape": "^1.5.1", "diagram-js": "^12.0.0", "dmn-font": "^0.6.2", @@ -24852,6 +24865,7 @@ "dmn-js-literal-expression": { "version": "file:packages/dmn-js-literal-expression", "requires": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "diagram-js": "^12.0.0", "dmn-font": "^0.6.2", "dmn-js-shared": "^14.4.1", diff --git a/packages/dmn-js-decision-table/package.json b/packages/dmn-js-decision-table/package.json index bbb18c3d..3a575c6f 100644 --- a/packages/dmn-js-decision-table/package.json +++ b/packages/dmn-js-decision-table/package.json @@ -30,6 +30,7 @@ "inferno-test-utils": "~5.6.2" }, "dependencies": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "css.escape": "^1.5.1", "diagram-js": "^12.0.0", "dmn-js-shared": "^14.4.1", diff --git a/packages/dmn-js-decision-table/src/Editor.js b/packages/dmn-js-decision-table/src/Editor.js index 6245b839..cc3d3a5b 100644 --- a/packages/dmn-js-decision-table/src/Editor.js +++ b/packages/dmn-js-decision-table/src/Editor.js @@ -1,3 +1,4 @@ +import { DmnVariableResolverModule } from '@bpmn-io/dmn-variable-resolver'; import Viewer from './Viewer'; import addRuleModule from './features/add-rule'; @@ -76,7 +77,8 @@ export default class Editor extends Viewer { simpleDurationEditModule, simpleNumberEditModule, simpleStringEditModule, - simpleTimeEditModule + simpleTimeEditModule, + DmnVariableResolverModule ]; } diff --git a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCellContextMenu.js b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCellContextMenu.js index 4ab2aa33..105d7426 100644 --- a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCellContextMenu.js +++ b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputCellContextMenu.js @@ -79,6 +79,7 @@ export default class InputCellContextMenu extends Component { ); } diff --git a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputEditor.js b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputEditor.js index 67f32a85..cce280ea 100644 --- a/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputEditor.js +++ b/packages/dmn-js-decision-table/src/features/decision-table-head/editor/components/InputEditor.js @@ -10,6 +10,7 @@ export default class InputEditor extends Component { this.translate = context.injector ? context.injector.get('translate') : noopTranslate; this.expressionLanguages = context.injector.get('expressionLanguages', false); + this.variableResolver = context.injector.get('variableResolver', false); this.handleValue = (text) => { @@ -54,6 +55,11 @@ export default class InputEditor extends Component { } }; + _getVariables() { + return this.variableResolver && + this.variableResolver.getVariables(this.props.element); + } + render() { const { @@ -63,6 +69,8 @@ export default class InputEditor extends Component { const ExpressionEditor = this.getExpressionEditorComponent(); + const variables = this._getVariables(); + return (
@@ -92,7 +100,8 @@ export default class InputEditor extends Component { ].join(' ') } onInput={ this.handleValue } - value={ text || '' } /> + value={ text || '' } + variables={ variables } />
); diff --git a/packages/dmn-js-literal-expression/package.json b/packages/dmn-js-literal-expression/package.json index 026e358c..71505fc4 100644 --- a/packages/dmn-js-literal-expression/package.json +++ b/packages/dmn-js-literal-expression/package.json @@ -30,6 +30,7 @@ "inferno-test-utils": "~5.6.2" }, "dependencies": { + "@bpmn-io/dmn-variable-resolver": "^0.3.0", "diagram-js": "^12.0.0", "dmn-js-shared": "^14.4.1", "escape-html": "^1.0.3", diff --git a/packages/dmn-js-shared/src/components/LiteralExpression.js b/packages/dmn-js-shared/src/components/LiteralExpression.js index 1fbaecd3..37649fa7 100644 --- a/packages/dmn-js-shared/src/components/LiteralExpression.js +++ b/packages/dmn-js-shared/src/components/LiteralExpression.js @@ -46,7 +46,8 @@ export default class LiteralExpression extends Component { this.editor = new FeelEditor({ container: this.node, onChange: this.handleChange, - value: this.state.value + value: this.state.value, + variables: this.props.variables || [], }); this.node.addEventListener('mousedown', this.handleMouseEvent); @@ -70,6 +71,10 @@ export default class LiteralExpression extends Component { this.editor.setValue(value); }); } + + if (prevProps.variables !== this.props.variables) { + this.editor.setVariables(this.props.variables); + } } componentWillUnmount() {