mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add filter to link node
This commit is contained in:
parent
2ce424b567
commit
139ae547c6
@ -773,10 +773,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
filter: function(filterFunc,expandResults) {
|
filter: function(filterFunc,expandResults) {
|
||||||
|
var totalCount = 0;
|
||||||
var filter = function(item) {
|
var filter = function(item) {
|
||||||
var matchCount = 0;
|
var matchCount = 0;
|
||||||
if (filterFunc && filterFunc(item)) {
|
if (filterFunc && filterFunc(item)) {
|
||||||
matchCount++;
|
matchCount++;
|
||||||
|
totalCount++;
|
||||||
}
|
}
|
||||||
var childCount = 0;
|
var childCount = 0;
|
||||||
if (item.children && typeof item.children !== "function") {
|
if (item.children && typeof item.children !== "function") {
|
||||||
@ -799,11 +801,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!filterFunc) {
|
if (!filterFunc) {
|
||||||
|
totalCount++;
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return matchCount > 0
|
return matchCount > 0
|
||||||
}
|
}
|
||||||
return this._topList.editableList('filter', filter);
|
this._topList.editableList('filter', filter);
|
||||||
|
return totalCount;
|
||||||
},
|
},
|
||||||
get: function(id) {
|
get: function(id) {
|
||||||
return this._items[id] || null;
|
return this._items[id] || null;
|
||||||
|
@ -81,4 +81,8 @@
|
|||||||
i.fa-times,i.fa-search {
|
i.fa-times,i.fa-search {
|
||||||
top: 7px;
|
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");
|
var editorRow = $("#dialog-form>div.node-input-target-list-row");
|
||||||
editorRow.css("height",height+"px");
|
editorRow.css("height",height+"px");
|
||||||
};
|
};
|
||||||
$("#node-input-complete-target-filter").searchBox({
|
var search = $("#node-input-complete-target-filter").searchBox({
|
||||||
style: "compact",
|
style: "compact",
|
||||||
delay: 300,
|
delay: 300,
|
||||||
change: function() {
|
change: function() {
|
||||||
var val = $(this).val().trim();
|
var val = $(this).val().trim();
|
||||||
if (val === "") {
|
if (val === "") {
|
||||||
dirList.treeList("filter", null);
|
dirList.treeList("filter", null);
|
||||||
|
search.searchBox("count","");
|
||||||
} else {
|
} else {
|
||||||
dirList.treeList("filter", function(item) {
|
var count = dirList.treeList("filter", function(item) {
|
||||||
return item.label.indexOf(val) > -1
|
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");
|
var editorRow = $("#dialog-form>div.node-input-target-list-row");
|
||||||
editorRow.css("height",height+"px");
|
editorRow.css("height",height+"px");
|
||||||
};
|
};
|
||||||
$("#node-input-catch-target-filter").searchBox({
|
var search = $("#node-input-catch-target-filter").searchBox({
|
||||||
style: "compact",
|
style: "compact",
|
||||||
delay: 300,
|
delay: 300,
|
||||||
change: function() {
|
change: function() {
|
||||||
var val = $(this).val().trim();
|
var val = $(this).val().trim();
|
||||||
if (val === "") {
|
if (val === "") {
|
||||||
dirList.treeList("filter", null);
|
dirList.treeList("filter", null);
|
||||||
|
search.searchBox("count","");
|
||||||
} else {
|
} else {
|
||||||
dirList.treeList("filter", function(item) {
|
var count = dirList.treeList("filter", function(item) {
|
||||||
return item.label.indexOf(val) > -1
|
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");
|
var editorRow = $("#dialog-form>div.node-input-target-list-row");
|
||||||
editorRow.css("height",height+"px");
|
editorRow.css("height",height+"px");
|
||||||
};
|
};
|
||||||
$("#node-input-status-target-filter").searchBox({
|
var search = $("#node-input-status-target-filter").searchBox({
|
||||||
style: "compact",
|
style: "compact",
|
||||||
delay: 300,
|
delay: 300,
|
||||||
change: function() {
|
change: function() {
|
||||||
var val = $(this).val().trim();
|
var val = $(this).val().trim();
|
||||||
if (val === "") {
|
if (val === "") {
|
||||||
dirList.treeList("filter", null);
|
dirList.treeList("filter", null);
|
||||||
|
search.searchBox("count","");
|
||||||
} else {
|
} else {
|
||||||
dirList.treeList("filter", function(item) {
|
var count = dirList.treeList("filter", function(item) {
|
||||||
return item.label.indexOf(val) > -1
|
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>
|
<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">
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||||
</div>
|
</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>
|
<div class="form-row node-input-link-row"></div>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" data-template-name="link out">
|
<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>
|
<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">
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||||
</div>
|
</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>
|
<div class="form-row node-input-link-row"></div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -47,6 +49,24 @@
|
|||||||
});
|
});
|
||||||
var candidateNodes = RED.nodes.filterNodes({type:targetType});
|
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 flows = [];
|
||||||
var flowMap = {};
|
var flowMap = {};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user