Skip to content

Commit 55daea6

Browse files
committed
fix: do not show local task variables in the autocompletion
Closes #58
1 parent b3e88ec commit 55daea6

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

lib/ElementVariables.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import EventEmitter from 'events';
22

3+
import { is } from 'bpmn-js/lib/util/ModelUtil';
4+
35
export class ElementVariables extends EventEmitter {
46
constructor(injector) {
57
super();
@@ -27,8 +29,10 @@ export class ElementVariables extends EventEmitter {
2729
return [];
2830
});
2931

30-
this._variables[element.id] = variables;
32+
const processVariables = variables.filter(({ scope }) => is(scope, 'bpmn:Process'));
33+
34+
this._variables[element.id] = processVariables;
3135

32-
return variables;
36+
return processVariables;
3337
}
3438
}

lib/components/Input/InputEditor.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import theme from '../shared/CodeMirrorTheme';
1717

1818
import { getAutocompletionExtensions } from '../../utils/autocompletion';
1919

20+
import { SCOPES } from '../../TaskExecution';
21+
2022
const fromPropAnnotation = Annotation.define();
2123

2224
const autocompletionCompartment = new Compartment();
@@ -203,7 +205,11 @@ function getAllOutputVariables(allOutputs) {
203205
return;
204206
}
205207

206-
const { name, value } = /** @type {Object} */ (variable);
208+
const { name, value, scope } = /** @type {Object} */ (variable);
209+
210+
if (scope !== SCOPES.PROCESS) {
211+
return;
212+
}
207213

208214
allOutputVariables.push({ name, value, origin: elementId });
209215
});

test/components/Input/InputEditor.spec.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import InputEditor, { PLACEHOLDER_TEXT, INVALID_JSON_ERROR } from '../../../lib/
99

1010
import diagramXML from '../../fixtures/InputEditor.bpmn';
1111

12+
import { SCOPES } from '../../../lib/TaskExecution';
13+
1214
describe('InputEditor', function() {
1315

1416
beforeEach(bootstrapModeler(diagramXML));
@@ -79,19 +81,22 @@ describe('InputEditor', function() {
7981
variables: {
8082
1: {
8183
name: 'foo',
82-
value: '1'
84+
value: '1',
85+
scope: SCOPES.PROCESS
8386
},
8487
2: {
8588
name: 'bar',
86-
value: '2'
89+
value: '2',
90+
scope: SCOPES.LOCAL
8791
},
8892
}
8993
},
9094
'ServiceTask_2': {
9195
variables: {
9296
3: {
9397
name: 'foo',
94-
value: '3'
98+
value: '3',
99+
scope: SCOPES.PROCESS
95100
},
96101
}
97102
}
@@ -110,11 +115,10 @@ describe('InputEditor', function() {
110115
await waitFor(() => {
111116
const completionLabels = Array.from(container.querySelectorAll('.cm-completionLabel')).map(el => el.textContent);
112117

113-
expect(completionLabels.length).to.eql(3);
118+
expect(completionLabels.length).to.eql(2);
114119

115-
expect(completionLabels[0]).to.eql('bar');
120+
expect(completionLabels[0]).to.eql('foo');
116121
expect(completionLabels[1]).to.eql('foo');
117-
expect(completionLabels[2]).to.eql('foo');
118122

119123
const completionInfos = Array.from(container.querySelectorAll('.cm-completionInfo .info span')).map(el => el.textContent);
120124

0 commit comments

Comments
 (0)