Add filter to link node

This commit is contained in:
Nick O'Leary 2020-06-03 15:54:51 +01:00
parent 2ce424b567
commit 139ae547c6
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 41 additions and 7 deletions

View File

@ -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;

View File

@ -81,4 +81,8 @@
i.fa-times,i.fa-search {
top: 7px;
}
.red-ui-searchBox-resultCount {
top: 3px;
padding: 0 6px;
}
}

View File

@ -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);
}
}
});

View File

@ -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);
}
}
});

View File

@ -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);
}
}
});

View File

@ -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 = {};