Skip to content

Commit

Permalink
feat: implement variable suggestions for literal expression
Browse files Browse the repository at this point in the history
Closes #785
  • Loading branch information
barmac committed Oct 12, 2023
1 parent 63841af commit cb3e5f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/dmn-js-literal-expression/src/Editor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DmnVariableResolverModule } from '@bpmn-io/dmn-variable-resolver';

import ExpressionLanguagesModule from 'dmn-js-shared/lib/features/expression-languages';
import DataTypesModule from 'dmn-js-shared/lib/features/data-types';

Expand Down Expand Up @@ -26,7 +28,8 @@ export default class Editor extends Viewer {
ModelingModule,
ExpressionLanguagesModule,
DataTypesModule,
TextareaEditorComponent
TextareaEditorComponent,
DmnVariableResolverModule
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class TextareaEditorComponent extends Component {

this._viewer = context.injector.get('viewer');
this._expressionLanguages = context.injector.get('expressionLanguages');
this._variableResolver = context.injector.get('variableResolver', false);

this.editLiteralExpressionText = this.editLiteralExpressionText.bind(this);
this.onElementsChanged = this.onElementsChanged.bind(this);
Expand Down Expand Up @@ -49,17 +50,26 @@ export default class TextareaEditorComponent extends Component {
this._expressionLanguages.getDefault().value;
}

_getVariables() {
const businessObject = this.getLiteralExpression();

return this._variableResolver &&
this._variableResolver.getVariables(businessObject);
}

render() {

// there is only one single element
const { text } = this.getLiteralExpression();
const Editor = this.getEditor();
const variables = this._getVariables();

return (
<Editor
className="textarea editor"
value={ text }
onChange={ this.editLiteralExpressionText } />
onChange={ this.editLiteralExpressionText }
variables={ variables } />
);
}
}
Expand All @@ -70,6 +80,7 @@ class FeelEditor extends Component {
className={ this.props.className }
value={ this.props.value }
onInput={ this.props.onChange }
variables={ this.props.variables }
/>;
}
}
Expand Down

0 comments on commit cb3e5f9

Please sign in to comment.