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

Add 'no matches' message to package search results

This commit is contained in:
Nick O'Leary 2016-09-30 11:19:47 +01:00
parent 2e87ebe800
commit e3b7c5fce7
2 changed files with 117 additions and 106 deletions

View File

@ -352,6 +352,10 @@ RED.palette.editor = (function() {
for (var i=0;i<Math.min(10,filteredList.length);i++) {
packageList.editableList('addItem',filteredList[i]);
}
if (filteredList.length === 0) {
packageList.editableList('addItem',{});
}
if (filteredList.length > 10) {
packageList.editableList('addItem',{start:10,more:filteredList.length-10})
}
@ -430,6 +434,7 @@ RED.palette.editor = (function() {
nodeList = $('<ol>',{id:"palette-module-list", style:"position: absolute;top: 35px;bottom: 0;left: 0;right: 0px;"}).appendTo(modulesTab).editableList({
addButton: false,
scrollOnAdd: false,
sort: function(A,B) {
return A.info.name.localeCompare(B.info.name);
},
@ -442,6 +447,7 @@ RED.palette.editor = (function() {
},
addItem: function(container,i,object) {
var entry = object.info;
if (entry) {
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>').html(entry.name).appendTo(titleRow);
@ -526,6 +532,9 @@ RED.palette.editor = (function() {
evt.preventDefault();
})
refreshNodeModule(entry.name);
} else {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
}
}
});
@ -546,10 +555,9 @@ RED.palette.editor = (function() {
.appendTo(searchDiv)
.searchBox({
delay: 300,
minimumLength: 2,
change: function() {
var searchTerm = $(this).val();
if (searchTerm.length >= 2) {
if (searchTerm.length > 0) {
filteredList = loadedList.filter(function(m) {
return (m.index.indexOf(searchTerm) > -1);
}).map(function(f) { return {info:f}});
@ -557,11 +565,9 @@ RED.palette.editor = (function() {
searchInput.searchBox('count',filteredList.length+" / "+loadedList.length);
} else {
searchInput.searchBox('count',loadedList.length);
if (searchTerm.length === 0) {
packageList.editableList('empty');
}
}
}
});
@ -603,7 +609,9 @@ RED.palette.editor = (function() {
packageList = $('<ol>',{style:"position: absolute;top: 78px;bottom: 0;left: 0;right: 0px;"}).appendTo(installTab).editableList({
addButton: false,
scrollOnAdd: false,
addItem: function(container,i,object) {
if (object.more) {
container.addClass('palette-module-more');
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
@ -620,6 +628,7 @@ RED.palette.editor = (function() {
})
return;
}
if (object.info) {
var entry = object.info;
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
@ -652,6 +661,9 @@ RED.palette.editor = (function() {
object.elements = {
installButton:installButton
}
} else {
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
}
}
});

View File

@ -101,6 +101,5 @@
padding: 10px;
text-align: center;
font-style: italic;
background: $background-color;
color: $form-placeholder-color;
}