From 139ae547c623f725f326a874197ae04836218633 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 3 Jun 2020 15:54:51 +0100 Subject: [PATCH] Add filter to link node --- .../src/js/ui/common/treeList.js | 6 +++++- .../src/sass/ui/common/searchBox.scss | 4 ++++ .../nodes/core/common/24-complete.html | 6 ++++-- .../@node-red/nodes/core/common/25-catch.html | 6 ++++-- .../nodes/core/common/25-status.html | 6 ++++-- .../@node-red/nodes/core/common/60-link.html | 20 +++++++++++++++++++ 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js index 486eae53b..d6313422a 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js @@ -773,10 +773,12 @@ } }, filter: function(filterFunc,expandResults) { + var totalCount = 0; var filter = function(item) { var matchCount = 0; if (filterFunc && filterFunc(item)) { matchCount++; + totalCount++; } var childCount = 0; if (item.children && typeof item.children !== "function") { @@ -799,11 +801,13 @@ } } if (!filterFunc) { + totalCount++; return true } return matchCount > 0 } - return this._topList.editableList('filter', filter); + this._topList.editableList('filter', filter); + return totalCount; }, get: function(id) { return this._items[id] || null; diff --git a/packages/node_modules/@node-red/editor-client/src/sass/ui/common/searchBox.scss b/packages/node_modules/@node-red/editor-client/src/sass/ui/common/searchBox.scss index b37e6e5fc..bb51d9969 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/ui/common/searchBox.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/ui/common/searchBox.scss @@ -81,4 +81,8 @@ i.fa-times,i.fa-search { top: 7px; } + .red-ui-searchBox-resultCount { + top: 3px; + padding: 0 6px; + } } \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/core/common/24-complete.html b/packages/node_modules/@node-red/nodes/core/common/24-complete.html index 4efeec382..0919326de 100644 --- a/packages/node_modules/@node-red/nodes/core/common/24-complete.html +++ b/packages/node_modules/@node-red/nodes/core/common/24-complete.html @@ -46,17 +46,19 @@ var editorRow = $("#dialog-form>div.node-input-target-list-row"); editorRow.css("height",height+"px"); }; - $("#node-input-complete-target-filter").searchBox({ + var search = $("#node-input-complete-target-filter").searchBox({ style: "compact", delay: 300, change: function() { var val = $(this).val().trim(); if (val === "") { dirList.treeList("filter", null); + search.searchBox("count",""); } else { - dirList.treeList("filter", function(item) { + var count = dirList.treeList("filter", function(item) { return item.label.indexOf(val) > -1 }); + search.searchBox("count",count+" / "+candidateNodes.length); } } }); 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 a13d769d1..066fb6ee2 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 @@ -61,17 +61,19 @@ var editorRow = $("#dialog-form>div.node-input-target-list-row"); editorRow.css("height",height+"px"); }; - $("#node-input-catch-target-filter").searchBox({ + var search = $("#node-input-catch-target-filter").searchBox({ style: "compact", delay: 300, change: function() { var val = $(this).val().trim(); if (val === "") { dirList.treeList("filter", null); + search.searchBox("count",""); } else { - dirList.treeList("filter", function(item) { + var count = dirList.treeList("filter", function(item) { return item.label.indexOf(val) > -1 }); + search.searchBox("count",count+" / "+candidateNodes.length); } } }); diff --git a/packages/node_modules/@node-red/nodes/core/common/25-status.html b/packages/node_modules/@node-red/nodes/core/common/25-status.html index 1f517a4aa..00831330b 100644 --- a/packages/node_modules/@node-red/nodes/core/common/25-status.html +++ b/packages/node_modules/@node-red/nodes/core/common/25-status.html @@ -49,17 +49,19 @@ var editorRow = $("#dialog-form>div.node-input-target-list-row"); editorRow.css("height",height+"px"); }; - $("#node-input-status-target-filter").searchBox({ + var search = $("#node-input-status-target-filter").searchBox({ style: "compact", delay: 300, change: function() { var val = $(this).val().trim(); if (val === "") { dirList.treeList("filter", null); + search.searchBox("count",""); } else { - dirList.treeList("filter", function(item) { + var count = dirList.treeList("filter", function(item) { return item.label.indexOf(val) > -1 }); + search.searchBox("count",count+" / "+candidateNodes.length); } } }); diff --git a/packages/node_modules/@node-red/nodes/core/common/60-link.html b/packages/node_modules/@node-red/nodes/core/common/60-link.html index cadf43efa..c3424830e 100644 --- a/packages/node_modules/@node-red/nodes/core/common/60-link.html +++ b/packages/node_modules/@node-red/nodes/core/common/60-link.html @@ -4,6 +4,7 @@ +
@@ -47,6 +49,24 @@ }); var candidateNodes = RED.nodes.filterNodes({type:targetType}); + var search = $("#node-input-link-target-filter").searchBox({ + style: "compact", + delay: 300, + change: function() { + var val = $(this).val().trim(); + if (val === "") { + treeList.treeList("filter", null); + search.searchBox("count",""); + } else { + var count = treeList.treeList("filter", function(item) { + return item.label.indexOf(val) > -1 + }); + search.searchBox("count",count+" / "+candidateNodes.length); + } + } + }); + + var flows = []; var flowMap = {};