🐛 Fix issue that expressions did not resolve for displayOptions

This commit is contained in:
Jan Oberhauser 2021-05-15 00:28:51 -05:00
parent 05dc0c327e
commit cb2887a8ab
3 changed files with 51 additions and 6 deletions

View file

@ -466,7 +466,7 @@ export default mixins(
} else if (typeof nodeParameters[key] === 'object') { } else if (typeof nodeParameters[key] === 'object') {
returnData[key] = this.getResolveNodeParameters(nodeParameters[key] as INodeParameters); returnData[key] = this.getResolveNodeParameters(nodeParameters[key] as INodeParameters);
} else { } else {
returnData[key] = this.resolveExpression(nodeParameters[key] as string); returnData[key] = this.resolveExpression(nodeParameters[key] as string, nodeParameters);
} }
} }
return returnData; return returnData;

View file

@ -86,7 +86,7 @@ import { IUpdateInformation } from '@/Interface';
import MultipleParameter from '@/components/MultipleParameter.vue'; import MultipleParameter from '@/components/MultipleParameter.vue';
import { genericHelpers } from '@/components/mixins/genericHelpers'; import { genericHelpers } from '@/components/mixins/genericHelpers';
import { nodeHelpers } from '@/components/mixins/nodeHelpers'; import { workflowHelpers } from '@/components/mixins/workflowHelpers';
import ParameterInputFull from '@/components/ParameterInputFull.vue'; import ParameterInputFull from '@/components/ParameterInputFull.vue';
import { get } from 'lodash'; import { get } from 'lodash';
@ -95,7 +95,7 @@ import mixins from 'vue-typed-mixins';
export default mixins( export default mixins(
genericHelpers, genericHelpers,
nodeHelpers, workflowHelpers,
) )
.extend({ .extend({
name: 'ParameterInputList', name: 'ParameterInputList',
@ -157,7 +157,41 @@ export default mixins(
// If it is not defined no need to do a proper check // If it is not defined no need to do a proper check
return true; return true;
} }
return this.displayParameter(this.nodeValues, parameter, this.path);
const nodeValues = {};
let rawValues = this.nodeValues;
if (this.path) {
rawValues = get(this.nodeValues, this.path);
}
// Resolve expressions
const resolveKeys = Object.keys(rawValues);
let key: string;
let i = 0;
do {
key = resolveKeys.shift();
if (typeof rawValues[key] === 'string' && rawValues[key].charAt(0) === '=') {
// Contains an expression that
if (rawValues[key].includes('$parameter') && resolveKeys.some(parameterName => rawValues[key].includes(parameterName))) {
// Contains probably an expression of a missing parameter so skip
resolveKeys.push(key);
continue;
} else {
// Contains probably no expression with a missing parameter so resolve
nodeValues[key] = this.resolveExpression(rawValues[key], nodeValues);
}
} else {
// Does not contain an expression, add directly
nodeValues[key] = rawValues[key];
}
// TODO: Think about how to calculate this best
if (i++ > 50) {
// Make sure we do not get caught
break;
}
} while(resolveKeys.length !== 0);
return this.displayParameter(nodeValues, parameter, '');
}, },
valueChanged (parameterData: IUpdateInformation): void { valueChanged (parameterData: IUpdateInformation): void {
this.$emit('valueChanged', parameterData); this.$emit('valueChanged', parameterData);

View file

@ -2,9 +2,11 @@ import { PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants';
import { import {
IConnections, IConnections,
IDataObject,
INode, INode,
INodeExecutionData, INodeExecutionData,
INodeIssues, INodeIssues,
INodeParameters,
INodeType, INodeType,
INodeTypes, INodeTypes,
INodeTypeData, INodeTypeData,
@ -336,7 +338,7 @@ export const workflowHelpers = mixins(
}, },
// Executes the given expression and returns its value // Executes the given expression and returns its value
resolveExpression (expression: string) { resolveExpression (expression: string, siblingParameters: INodeParameters) {
const inputIndex = 0; const inputIndex = 0;
const itemIndex = 0; const itemIndex = 0;
const runIndex = 0; const runIndex = 0;
@ -362,7 +364,16 @@ export const workflowHelpers = mixins(
connectionInputData = []; connectionInputData = [];
} }
return workflow.expression.getParameterValue(expression, runExecutionData, runIndex, itemIndex, activeNode.name, connectionInputData, 'manual', true); const parameters = {
'__xxxxxxx__': expression,
...siblingParameters,
};
const returnData = workflow.expression.getParameterValue(parameters, runExecutionData, runIndex, itemIndex, activeNode.name, connectionInputData, 'manual', false) as IDataObject;
if (typeof returnData['__xxxxxxx__'] === 'object') {
return workflow.expression.convertObjectValueToString(returnData['__xxxxxxx__'] as object);
}
return returnData['__xxxxxxx__'];
}, },
// Saves the currently loaded workflow to the database. // Saves the currently loaded workflow to the database.