mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Add filter to link node
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -81,4 +81,8 @@ | ||||
|     i.fa-times,i.fa-search { | ||||
|         top: 7px; | ||||
|     } | ||||
|     .red-ui-searchBox-resultCount { | ||||
|         top: 3px; | ||||
|         padding: 0 6px; | ||||
|     } | ||||
| } | ||||
| @@ -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); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|   | ||||
| @@ -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); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|   | ||||
| @@ -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); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
|         <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label> | ||||
|         <input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name"> | ||||
|     </div> | ||||
|     <div style="position:relative; height: 30px; text-align: right;"><div style="display:inline-block"><input type="text" id="node-input-link-target-filter"></div></div> | ||||
|     <div class="form-row node-input-link-row"></div> | ||||
| </script> | ||||
| <script type="text/html" data-template-name="link out"> | ||||
| @@ -11,6 +12,7 @@ | ||||
|         <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label> | ||||
|         <input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name"> | ||||
|     </div> | ||||
|     <div style="position:relative; height: 30px; text-align: right;"><div style="display:inline-block"><input type="text" id="node-input-link-target-filter"></div></div> | ||||
|     <div class="form-row node-input-link-row"></div> | ||||
| </script> | ||||
|  | ||||
| @@ -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 = {}; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user