mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
populate workflow Inputs
This commit is contained in:
parent
0a924e0dd3
commit
0ffc72a8a3
|
@ -199,7 +199,7 @@ export class ExecuteWorkflow implements INodeType {
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
loadOptionsDependsOn: ['workflowId.value'],
|
loadOptionsDependsOn: ['workflowId.value', 'workflowJson'],
|
||||||
resourceMapper: {
|
resourceMapper: {
|
||||||
resourceMapperMethod: 'getWorkflowInputs',
|
resourceMapperMethod: 'getWorkflowInputs',
|
||||||
mode: 'add',
|
mode: 'add',
|
||||||
|
@ -214,11 +214,11 @@ export class ExecuteWorkflow implements INodeType {
|
||||||
},
|
},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
source: ['database'],
|
|
||||||
'@version': [{ _cnd: { gte: 1.2 } }],
|
'@version': [{ _cnd: { gte: 1.2 } }],
|
||||||
},
|
},
|
||||||
hide: {
|
hide: {
|
||||||
workflowId: [''],
|
workflowId: [''],
|
||||||
|
workflowJson: ['\n\n\n'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,22 +1,42 @@
|
||||||
import type {
|
import type {
|
||||||
|
FieldType,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
ResourceMapperField,
|
ResourceMapperField,
|
||||||
ResourceMapperFields,
|
ResourceMapperFields,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
import { getWorkflowInfo } from '../GenericFunctions';
|
||||||
|
|
||||||
export async function getWorkflowInputs(
|
export async function getWorkflowInputs(
|
||||||
this: ILoadOptionsFunctions,
|
this: ILoadOptionsFunctions,
|
||||||
): Promise<ResourceMapperFields> {
|
): Promise<ResourceMapperFields> {
|
||||||
// TODO: take the columns from the workflow input
|
const source = this.getNodeParameter('source', 0) as string;
|
||||||
const workflowInputs = ['uid', 'Test Field 2', 'Test Field 3'];
|
|
||||||
|
|
||||||
const fields: ResourceMapperField[] = workflowInputs.map((col) => ({
|
const executeWorkflowInfo = await getWorkflowInfo.call(this, source);
|
||||||
id: col,
|
|
||||||
displayName: col,
|
if (executeWorkflowInfo.code === undefined) {
|
||||||
|
// executeWorkflowInfo.code = await getWorkflowById.call(this, executeWorkflowInfo.id as string);
|
||||||
|
}
|
||||||
|
|
||||||
|
const workflowInputs = (
|
||||||
|
Array.isArray(
|
||||||
|
executeWorkflowInfo.code?.nodes.find(
|
||||||
|
(node) => node.type === 'n8n-nodes-base.executeWorkflowTrigger',
|
||||||
|
)?.parameters.workflowInputs,
|
||||||
|
)
|
||||||
|
? executeWorkflowInfo.code?.nodes.find(
|
||||||
|
(node) => node.type === 'n8n-nodes-base.executeWorkflowTrigger',
|
||||||
|
)?.parameters.workflowInputs
|
||||||
|
: []
|
||||||
|
) as Array<{ name: string; type: FieldType }>;
|
||||||
|
|
||||||
|
const fields: ResourceMapperField[] = workflowInputs.map((currentWorkflowInput) => ({
|
||||||
|
id: currentWorkflowInput.name,
|
||||||
|
displayName: currentWorkflowInput.name,
|
||||||
required: false,
|
required: false,
|
||||||
defaultMatch: true,
|
defaultMatch: true,
|
||||||
display: true,
|
display: true,
|
||||||
type: 'number',
|
type: currentWorkflowInput.type || 'string',
|
||||||
canBeUsedToMatch: true,
|
canBeUsedToMatch: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue