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 visible = false;
|
||||||
|
|
||||||
var filterTerm = "";
|
var filterTerm = "";
|
||||||
|
var filterTerms = [];
|
||||||
var previousActiveElement;
|
var previousActiveElement;
|
||||||
|
|
||||||
function ensureSelectedIsVisible() {
|
function ensureSelectedIsVisible() {
|
||||||
@ -46,7 +47,8 @@ RED.actionList = (function() {
|
|||||||
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
|
||||||
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
|
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
|
||||||
change: function() {
|
change: function() {
|
||||||
filterTerm = $(this).val();
|
filterTerm = $(this).val().trim();
|
||||||
|
filterTerms = filterTerm.split(" ");
|
||||||
searchResults.editableList('filter');
|
searchResults.editableList('filter');
|
||||||
searchResults.find("li.selected").removeClass("selected");
|
searchResults.find("li.selected").removeClass("selected");
|
||||||
var children = searchResults.children(":visible");
|
var children = searchResults.children(":visible");
|
||||||
@ -118,8 +120,17 @@ RED.actionList = (function() {
|
|||||||
},
|
},
|
||||||
scrollOnAdd: false,
|
scrollOnAdd: false,
|
||||||
filter: function(item) {
|
filter: function(item) {
|
||||||
if (filterTerm !== "" && item.label.toLowerCase().indexOf(filterTerm) === -1) {
|
if (filterTerm !== "") {
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -159,6 +170,7 @@ RED.actionList = (function() {
|
|||||||
});
|
});
|
||||||
actions.forEach(function(action) {
|
actions.forEach(function(action) {
|
||||||
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
|
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
|
||||||
|
action._label = action.label.toLowerCase();
|
||||||
searchResults.editableList('addItem',action)
|
searchResults.editableList('addItem',action)
|
||||||
})
|
})
|
||||||
RED.events.emit("actionList:open");
|
RED.events.emit("actionList:open");
|
||||||
|
Loading…
Reference in New Issue
Block a user