mirror of https://github.com/node-red/node-red.git
Merge pull request #5309 from node-red/5308-small-catalogues
Show all catalog items if small enough and no search time providedpull/5310/head
commit
49f6c1b0fe
|
|
@ -40,6 +40,8 @@ RED.palette.editor = (function() {
|
|||
// Install tab - search input
|
||||
let searchInput;
|
||||
|
||||
const SMALL_CATALOGUE_SIZE = 40
|
||||
|
||||
const typesInUse = {};
|
||||
|
||||
const semverre = /^(\d+)(\.(\d+))?(\.(\d+))?(-([0-9A-Za-z-]+))?(\.([0-9A-Za-z-.]+))?$/;
|
||||
|
|
@ -643,14 +645,14 @@ RED.palette.editor = (function() {
|
|||
return (m.catalog.name === selectedCatalog);
|
||||
})
|
||||
}
|
||||
refreshFilteredItems();
|
||||
searchInput.searchBox('change')
|
||||
searchInput.searchBox('count',filteredList.length+" / "+loadedList.length);
|
||||
}
|
||||
|
||||
function refreshFilteredItems() {
|
||||
packageList.editableList('empty');
|
||||
var currentFilter = searchInput.searchBox('value').trim();
|
||||
if (currentFilter === "" && loadedList.length > 20){
|
||||
if (currentFilter === "" && loadedList.length > SMALL_CATALOGUE_SIZE){
|
||||
packageList.editableList('addItem',{count:loadedList.length})
|
||||
return;
|
||||
}
|
||||
|
|
@ -1204,7 +1206,7 @@ RED.palette.editor = (function() {
|
|||
delay: 300,
|
||||
change: function() {
|
||||
var searchTerm = $(this).val().trim().toLowerCase();
|
||||
if (searchTerm.length > 0 || loadedList.length < 20) {
|
||||
if (searchTerm.length > 0 || loadedList.length < SMALL_CATALOGUE_SIZE) {
|
||||
const searchTerms = []
|
||||
searchTerm.split(',').forEach(term => {
|
||||
term = term.trim()
|
||||
|
|
@ -1217,6 +1219,10 @@ RED.palette.editor = (function() {
|
|||
}
|
||||
})
|
||||
filteredList = loadedList.filter(function(m) {
|
||||
if (searchTerms.length === 0 && loadedList.length < SMALL_CATALOGUE_SIZE) {
|
||||
// Show all items if the catalogue is small enough and there is no search term
|
||||
return true
|
||||
}
|
||||
for (let i = 0; i < searchTerms.length; i++) {
|
||||
const location = m.index.indexOf(searchTerms[i].term)
|
||||
if (
|
||||
|
|
|
|||
Loading…
Reference in New Issue