Add "isEmpty" option to IF-Node

This commit is contained in:
Jan Oberhauser 2020-12-11 18:15:07 +01:00
parent cfc222a877
commit 3e0b9f2eba

View file

@ -112,6 +112,10 @@ export class If implements INodeType {
name: 'Larger Equal', name: 'Larger Equal',
value: 'largerEqual', value: 'largerEqual',
}, },
{
name: 'Is Empty',
value: 'isEmpty',
},
], ],
default: 'smaller', default: 'smaller',
description: 'Operation to decide where the the data should be mapped to.', description: 'Operation to decide where the the data should be mapped to.',
@ -120,6 +124,13 @@ export class If implements INodeType {
displayName: 'Value 2', displayName: 'Value 2',
name: 'value2', name: 'value2',
type: 'number', type: 'number',
displayOptions: {
hide: {
operation: [
'isEmpty',
],
},
},
default: 0, default: 0,
description: 'The value to compare with the first one.', description: 'The value to compare with the first one.',
}, },
@ -161,6 +172,10 @@ export class If implements INodeType {
name: 'Regex', name: 'Regex',
value: 'regex', value: 'regex',
}, },
{
name: 'Is Empty',
value: 'isEmpty',
},
], ],
default: 'equal', default: 'equal',
description: 'Operation to decide where the the data should be mapped to.', description: 'Operation to decide where the the data should be mapped to.',
@ -172,6 +187,7 @@ export class If implements INodeType {
displayOptions: { displayOptions: {
hide: { hide: {
operation: [ operation: [
'isEmpty',
'regex', 'regex',
], ],
}, },
@ -242,6 +258,7 @@ export class If implements INodeType {
largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) >= (value2 || 0), largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) >= (value2 || 0),
smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0), smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0),
smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) <= (value2 || 0), smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) <= (value2 || 0),
isEmpty: (value1: NodeParameterValue) => [undefined, null, ''].includes(value1 as string),
regex: (value1: NodeParameterValue, value2: NodeParameterValue) => { regex: (value1: NodeParameterValue, value2: NodeParameterValue) => {
const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimy]*)$')); const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimy]*)$'));