Skip to content

Commit 1060cb8

Browse files
committed
fix: filter by uniqueness after filtering by scope
* also, don't filter out external variables Closes #54
1 parent 6537b64 commit 1060cb8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/base/VariableResolver.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,24 +258,32 @@ export class BaseVariableResolver {
258258
const root = getRootElement(bo);
259259
const allVariables = await this.getProcessVariables(root);
260260

261-
// keep only unique variables based on name property
262-
const uniqueVariables = uniqueBy('name', allVariables.reverse());
263-
264261
// (1) get variables for given scope
265-
var scopeVariables = uniqueVariables.filter(function(variable) {
262+
var scopeVariables = allVariables.filter(function(variable) {
266263
return variable.scope.id === bo.id;
267264
});
268265

269266
// (2) get variables for parent scopes
270267
var parents = getParents(bo);
271268

272-
var parentsScopeVariables = uniqueVariables.filter(function(variable) {
269+
var parentsScopeVariables = allVariables.filter(function(variable) {
273270
return parents.find(function(parent) {
274271
return parent.id === variable.scope.id;
275272
});
276273
});
277274

278-
return [ ...scopeVariables, ...parentsScopeVariables ];
275+
const reversedVariables = [ ...scopeVariables, ...parentsScopeVariables ].reverse();
276+
277+
return reversedVariables.filter(variable => {
278+
279+
// if external variable, keep
280+
if (variable.provider.find(extractor => extractor !== this._baseExtractor)) {
281+
return true;
282+
}
283+
284+
// if not external, keep only if first of its name
285+
return reversedVariables.find(v => v.name === variable.name) === variable;
286+
});
279287
}
280288
}
281289

0 commit comments

Comments
 (0)