mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
🐛 Fix issue that expressions did not resolve for displayOptions
This commit is contained in:
parent
05dc0c327e
commit
cb2887a8ab
|
@ -466,7 +466,7 @@ export default mixins(
|
|||
} else if (typeof nodeParameters[key] === 'object') {
|
||||
returnData[key] = this.getResolveNodeParameters(nodeParameters[key] as INodeParameters);
|
||||
} else {
|
||||
returnData[key] = this.resolveExpression(nodeParameters[key] as string);
|
||||
returnData[key] = this.resolveExpression(nodeParameters[key] as string, nodeParameters);
|
||||
}
|
||||
}
|
||||
return returnData;
|
||||
|
|
|
@ -86,7 +86,7 @@ import { IUpdateInformation } from '@/Interface';
|
|||
|
||||
import MultipleParameter from '@/components/MultipleParameter.vue';
|
||||
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 { get } from 'lodash';
|
||||
|
@ -95,7 +95,7 @@ import mixins from 'vue-typed-mixins';
|
|||
|
||||
export default mixins(
|
||||
genericHelpers,
|
||||
nodeHelpers,
|
||||
workflowHelpers,
|
||||
)
|
||||
.extend({
|
||||
name: 'ParameterInputList',
|
||||
|
@ -157,7 +157,41 @@ export default mixins(
|
|||
// If it is not defined no need to do a proper check
|
||||
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 {
|
||||
this.$emit('valueChanged', parameterData);
|
||||
|
|
|
@ -2,9 +2,11 @@ import { PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants';
|
|||
|
||||
import {
|
||||
IConnections,
|
||||
IDataObject,
|
||||
INode,
|
||||
INodeExecutionData,
|
||||
INodeIssues,
|
||||
INodeParameters,
|
||||
INodeType,
|
||||
INodeTypes,
|
||||
INodeTypeData,
|
||||
|
@ -336,7 +338,7 @@ export const workflowHelpers = mixins(
|
|||
},
|
||||
|
||||
// Executes the given expression and returns its value
|
||||
resolveExpression (expression: string) {
|
||||
resolveExpression (expression: string, siblingParameters: INodeParameters) {
|
||||
const inputIndex = 0;
|
||||
const itemIndex = 0;
|
||||
const runIndex = 0;
|
||||
|
@ -362,7 +364,16 @@ export const workflowHelpers = mixins(
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue