From 42ac3ef9af8d3f2fcbd6b1c31d2ef74c49410e44 Mon Sep 17 00:00:00 2001 From: Joshi Date: Mon, 23 Mar 2020 13:21:22 -0700 Subject: [PATCH] Implements two new operations - is one of and is not one of that evaluates to true if telemetry matches one of many values --- src/plugins/condition/utils/operations.js | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/plugins/condition/utils/operations.js b/src/plugins/condition/utils/operations.js index fc72f77440..a9aa1ea7f7 100644 --- a/src/plugins/condition/utils/operations.js +++ b/src/plugins/condition/utils/operations.js @@ -202,5 +202,31 @@ export const OPERATIONS = [ getDescription: function (values) { return ' is not ' + values[0]; } + }, + { + name: 'valueIs', + operation: function (input) { + const values = input[1].split(','); + return values.find((value) => input[0].toString() === value.toString().replace(' ', '')); + }, + text: 'is one of', + appliesTo: ["string", "number"], + inputCount: 1, + getDescription: function (values) { + return ' is one of ' + values[0]; + } + }, + { + name: 'valueIsNot', + operation: function (input) { + const values = input[1].split(','); + return values.find((value) => input[0].toString() !== value.toString().replace(' ', '')); + }, + text: 'is not one of', + appliesTo: ["string", "number"], + inputCount: 1, + getDescription: function (values) { + return ' is not one of ' + values[0]; + } } ];