From 371253a4f6fff9b11a83fcba0c323ac92e82f641 Mon Sep 17 00:00:00 2001 From: NetHans Date: Sun, 14 Aug 2022 20:28:34 +0200 Subject: [PATCH] catch node extended --- .../@node-red/nodes/core/common/25-catch.html | 5 +++++ .../@node-red/nodes/locales/de/messages.json | 1 + .../@node-red/nodes/locales/en-US/messages.json | 1 + .../node_modules/@node-red/runtime/lib/flows/Flow.js | 10 ++++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/25-catch.html b/packages/node_modules/@node-red/nodes/core/common/25-catch.html index 0b976ea78..4c591226d 100644 --- a/packages/node_modules/@node-red/nodes/core/common/25-catch.html +++ b/packages/node_modules/@node-red/nodes/core/common/25-catch.html @@ -4,6 +4,7 @@ @@ -170,6 +171,8 @@ }); if (this.scope === null) { $("#node-input-scope-select").val("all"); + } else if(this.scope === "group"){ + $("#node-input-scope-select").val("group"); } else { $("#node-input-scope-select").val("target"); } @@ -179,6 +182,8 @@ var scope = $("#node-input-scope-select").val(); if (scope === 'all') { this.scope = null; + } else if(scope === 'group') { + this.scope = "group"; } else { $("#node-input-uncaught").prop("checked",false); this.scope = $("#node-input-catch-target-container-div").treeList('selected').map(function(i) { return i.node.id}) diff --git a/packages/node_modules/@node-red/nodes/locales/de/messages.json b/packages/node_modules/@node-red/nodes/locales/de/messages.json index 2ae7ba3b8..edc881001 100755 --- a/packages/node_modules/@node-red/nodes/locales/de/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/de/messages.json @@ -98,6 +98,7 @@ }, "scope": { "all": "allen Nodes", + "group": "in gleicher Gruppe", "selected": "ausgewählten Nodes" } }, diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index 8318693b0..b600bda91 100644 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -103,6 +103,7 @@ }, "scope": { "all": "all nodes", + "group": "in same group", "selected": "selected nodes" } }, diff --git a/packages/node_modules/@node-red/runtime/lib/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/flows/Flow.js index 56c98be0e..7df148b7f 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/Flow.js @@ -734,11 +734,17 @@ class Flow { } else { var handledByUncaught = false; + const flow = this; this.catchNodes.forEach(function(targetCatchNode) { - if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) { + if (Array.isArray(targetCatchNode.scope) && targetCatchNode.scope.indexOf(reportingNode.id) === -1) { return; } - if (!targetCatchNode.scope && targetCatchNode.uncaught && !handledByUncaught) { + + if (targetCatchNode.scope === "group" && flow.isNodeInSameGroup(targetCatchNode, reportingNode) === false){ + return; + } + + if ((!targetCatchNode.scope || targetCatchNode.scope === "group") && targetCatchNode.uncaught && !handledByUncaught) { if (handled) { // This has been handled by a !uncaught catch node return;