1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Allow search results to show more than 25 results

This commit is contained in:
Nick O'Leary 2019-08-14 11:37:26 +01:00
parent 5bf9646a76
commit fe084a4478
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -125,6 +125,14 @@ RED.search = (function() {
for (i=0;i<Math.min(results.length,25);i++) {
searchResults.editableList('addItem',results[i])
}
if (results.length > 25) {
searchResults.editableList('addItem', {
more: {
results: results,
start: 25
}
})
}
} else {
searchResults.editableList('addItem',{});
}
@ -186,8 +194,27 @@ RED.search = (function() {
evt.preventDefault();
} else if (evt.keyCode === 13) {
// Enter
if (results.length > 0) {
reveal(results[Math.max(0,selected)].node);
children = searchResults.children();
if ($(children[selected]).hasClass("red-ui-search-more")) {
var object = $(children[selected]).find(".red-ui-editableList-item-content").data('data');
if (object) {
searchResults.editableList('removeItem',object);
for (i=object.more.start;i<Math.min(results.length,object.more.start+25);i++) {
searchResults.editableList('addItem',results[i])
}
if (results.length > object.more.start+25) {
searchResults.editableList('addItem', {
more: {
results: results,
start: object.more.start+25
}
})
}
}
} else {
if (results.length > 0) {
reveal(results[Math.max(0,selected)].node);
}
}
}
}
@ -199,12 +226,32 @@ RED.search = (function() {
addButton: false,
addItem: function(container,i,object) {
var node = object.node;
if (node === undefined) {
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
var div;
if (object.more) {
container.parent().addClass("red-ui-search-more")
div = $('<a>',{href:'#',class:"red-ui-search-result red-ui-search-empty"}).appendTo(container);
div.text(RED._("palette.editor.more",{count:object.more.results.length-object.more.start}));
div.on("click", function(evt) {
evt.preventDefault();
searchResults.editableList('removeItem',object);
for (i=object.more.start;i<Math.min(results.length,object.more.start+25);i++) {
searchResults.editableList('addItem',results[i])
}
if (results.length > object.more.start+25) {
searchResults.editableList('addItem', {
more: {
results: results,
start: object.more.start+25
}
})
}
});
} else if (node === undefined) {
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
} else {
var def = node._def;
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).appendTo(div);
var colour = RED.utils.getNodeColor(node.type,def);