🐛 Fix that "getCurrentNodeParameter" did not resolve expressions

This commit is contained in:
Jan Oberhauser
2019-12-16 20:27:56 -06:00
parent ae89882951
commit a7d729842a
5 changed files with 29 additions and 4 deletions

View File

@@ -125,6 +125,7 @@ import {
import {
NodeHelpers,
NodeParameterValue,
INodeParameters,
INodePropertyOptions,
Workflow,
} from 'n8n-workflow';
@@ -421,6 +422,21 @@ export default mixins(
},
},
methods: {
getResolveNodeParameters (nodeParameters: INodeParameters): INodeParameters {
const returnData: INodeParameters = {};
for (const key of Object.keys(nodeParameters)) {
if (Array.isArray(nodeParameters[key])) {
returnData[key] = (nodeParameters[key] as string[]).map(value => {
return this.resolveExpression(value as string) as string;
});
} else if (typeof nodeParameters[key] === 'object') {
returnData[key] = this.getResolveNodeParameters(nodeParameters[key] as INodeParameters);
} else {
returnData[key] = this.resolveExpression(nodeParameters[key] as string);
}
}
return returnData;
},
async loadRemoteParameterOptions () {
if (this.node === null || this.remoteMethod === undefined || this.remoteParameterOptionsLoading) {
return;
@@ -429,8 +445,12 @@ export default mixins(
this.remoteParameterOptionsLoading = true;
this.remoteParameterOptions.length = 0;
// Get the resolved parameter values of the current node
const currentNodeParameters = this.$store.getters.activeNode.parameters;
const resolvedNodeParameters = this.getResolveNodeParameters(currentNodeParameters);
try {
const options = await this.restApi().getNodeParameterOptions(this.node.type, this.remoteMethod, this.node.credentials);
const options = await this.restApi().getNodeParameterOptions(this.node.type, this.remoteMethod, resolvedNodeParameters, this.node.credentials);
this.remoteParameterOptions.push.apply(this.remoteParameterOptions, options);
} catch (error) {
this.remoteParameterOptionsLoadingIssues = error.message;