Show all catalog items if small enough and no search time provided

This commit is contained in:
Nick O'Leary
2025-10-13 10:56:40 +01:00
parent 5427d43a98
commit 6d1fd0b616

View File

@@ -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 (