mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Smarter filtering in action list dialog
This commit is contained in:
parent
a73c159160
commit
d11d389ae4
@ -23,6 +23,7 @@ RED.actionList = (function() {
|
||||
var visible = false;
|
||||
|
||||
var filterTerm = "";
|
||||
var filterTerms = [];
|
||||
var previousActiveElement;
|
||||
|
||||
function ensureSelectedIsVisible() {
|
||||
@ -46,7 +47,8 @@ RED.actionList = (function() {
|
||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
|
||||
change: function() {
|
||||
filterTerm = $(this).val();
|
||||
filterTerm = $(this).val().trim();
|
||||
filterTerms = filterTerm.split(" ");
|
||||
searchResults.editableList('filter');
|
||||
searchResults.find("li.selected").removeClass("selected");
|
||||
var children = searchResults.children(":visible");
|
||||
@ -118,8 +120,17 @@ RED.actionList = (function() {
|
||||
},
|
||||
scrollOnAdd: false,
|
||||
filter: function(item) {
|
||||
if (filterTerm !== "" && item.label.toLowerCase().indexOf(filterTerm) === -1) {
|
||||
return false;
|
||||
if (filterTerm !== "") {
|
||||
var pos=0;
|
||||
for (var i=0;i<filterTerms.length;i++) {
|
||||
var j = item._label.indexOf(filterTerms[i],pos);
|
||||
if (j > -1) {
|
||||
pos = j;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -159,6 +170,7 @@ RED.actionList = (function() {
|
||||
});
|
||||
actions.forEach(function(action) {
|
||||
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
|
||||
action._label = action.label.toLowerCase();
|
||||
searchResults.editableList('addItem',action)
|
||||
})
|
||||
RED.events.emit("actionList:open");
|
||||
|
Loading…
Reference in New Issue
Block a user