Add options "passThrough" and "wait" to Merge-Node

This commit is contained in:
Jan Oberhauser 2019-07-11 14:54:18 +02:00
parent 71ca59e3a8
commit afb078a62a

View file

@ -14,7 +14,7 @@ export class Merge implements INodeType {
icon: 'fa:clone', icon: 'fa:clone',
group: ['transform'], group: ['transform'],
version: 1, version: 1,
description: 'Merges data from multiple streams', description: 'Merges data of multiple streams once data of both is available',
defaults: { defaults: {
name: 'Merge', name: 'Merge',
color: '#00cc22', color: '#00cc22',
@ -29,11 +29,23 @@ export class Merge implements INodeType {
options: [ options: [
{ {
name: 'Append', name: 'Append',
value: 'append' value: 'append',
description: 'Combines data of both inputs. The output will contain items of input 1 and input 2.',
}, },
{ {
name: 'Merge', name: 'Merge',
value: 'merge' value: 'merge',
description: 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.',
},
{
name: 'Pass-through',
value: 'passThrough',
description: 'Passes through data of one input. The output will conain only items of the defined input.',
},
{
name: 'Wait',
value: 'wait',
description: 'Waits till data of both inputs is available and will then output a single empty item.',
}, },
], ],
default: 'append', default: 'append',
@ -44,6 +56,7 @@ export class Merge implements INodeType {
name: 'propertyName1', name: 'propertyName1',
type: 'string', type: 'string',
default: '', default: '',
required: true,
displayOptions: { displayOptions: {
show: { show: {
mode: [ mode: [
@ -58,6 +71,7 @@ export class Merge implements INodeType {
name: 'propertyName2', name: 'propertyName2',
type: 'string', type: 'string',
default: '', default: '',
required: true,
displayOptions: { displayOptions: {
show: { show: {
mode: [ mode: [
@ -67,6 +81,30 @@ export class Merge implements INodeType {
}, },
description: 'Name of property which decides which items to merge of input 2.', description: 'Name of property which decides which items to merge of input 2.',
}, },
{
displayName: 'Output Data',
name: 'output',
type: 'options',
displayOptions: {
show: {
mode: [
'passThrough'
],
},
},
options: [
{
name: 'Input 1',
value: 'input1',
},
{
name: 'Input 2',
value: 'input2',
},
],
default: 'input1',
description: 'Defines of which input the data should be used as output of node.',
},
] ]
}; };
@ -147,6 +185,16 @@ export class Merge implements INodeType {
} }
return [dataInput1]; return [dataInput1];
} else if (mode === 'passThrough') {
const output = this.getNodeParameter('output', 0) as string;
if (output === 'input1') {
returnData.push.apply(returnData, this.getInputData(0));
} else {
returnData.push.apply(returnData, this.getInputData(1));
}
} else if (mode === 'wait') {
returnData.push({ json: {} });
} }
return [returnData]; return [returnData];