ensure help search is case insensitive

This commit is contained in:
Steve-Mcl 2022-01-25 18:27:47 +00:00
parent faf31be0dc
commit 8b85f6e0a6
1 changed files with 26 additions and 17 deletions

View File

@ -64,15 +64,17 @@ RED.sidebar.help = (function() {
style: "compact", style: "compact",
delay: 100, delay: 100,
change: function() { change: function() {
var val = $(this).val().toLowerCase(); const searchFor = $(this).val().toLowerCase();
if (val) { if (searchFor) {
showTOC(); showTOC();
var c = treeList.treeList('filter',function(item) { treeList.treeList('filter',function(item) {
if (item.depth === 0) { if (item.depth === 0) {
return true; return true;
} }
return (item.nodeType && item.nodeType.indexOf(val) > -1) || let found = item.nodeType && item.nodeType.toLowerCase().indexOf(searchFor) > -1;
(item.subflowLabel && item.subflowLabel.indexOf(val) > -1) found = found || item.subflowLabel && item.subflowLabel.toLowerCase().indexOf(searchFor) > -1;
found = found || item.palleteLabel && item.palleteLabel.toLowerCase().indexOf(searchFor) > -1;
return found;
},true) },true)
} else { } else {
treeList.treeList('filter',null); treeList.treeList('filter',null);
@ -224,17 +226,21 @@ RED.sidebar.help = (function() {
moduleNames.forEach(function(moduleName) { moduleNames.forEach(function(moduleName) {
var module = modules[moduleName]; const module = modules[moduleName];
var nodeTypes = []; const nodeTypes = [];
const moduleSets = module.sets;
var setNames = Object.keys(module.sets); const setNames = Object.keys(moduleSets);
setNames.forEach(function(setName) { setNames.forEach(function(setName) {
module.sets[setName].types.forEach(function(nodeType) { const moduleSet = moduleSets[setName];
moduleSet.types.forEach(function(nodeType) {
if ($("script[data-help-name='"+nodeType+"']").length) { if ($("script[data-help-name='"+nodeType+"']").length) {
const n = {_def:RED.nodes.getType(nodeType),type:nodeType}
n.name = getNodePaletteLabel(n);
nodeTypes.push({ nodeTypes.push({
id: "node-type:"+nodeType, id: "node-type:"+nodeType,
nodeType: nodeType, nodeType: nodeType,
element:getNodeLabel({_def:RED.nodes.getType(nodeType),type:nodeType}) palleteLabel: n.name,
element: getNodeLabel(n)
}) })
} }
}) })
@ -254,18 +260,21 @@ RED.sidebar.help = (function() {
treeList.treeList("data",helpData); treeList.treeList("data",helpData);
} }
function getNodeLabel(n) { function getNodePaletteLabel(n) {
var div = $('<div>',{class:"red-ui-node-list-item"}); let label = n.name;
var icon = RED.utils.createNodeIcon(n).appendTo(div);
var label = n.name;
if (!label && n._def && n._def.paletteLabel) { if (!label && n._def && n._def.paletteLabel) {
try { try {
label = (typeof n._def.paletteLabel === "function" ? n._def.paletteLabel.call(n._def) : n._def.paletteLabel)||""; label = (typeof n._def.paletteLabel === "function" ? n._def.paletteLabel.call(n._def) : n._def.paletteLabel)||"";
} catch (err) { } catch (err) {
} }
} }
label = label || n.type; return label || n.type;
$('<div>',{class:"red-ui-node-label"}).text(label).appendTo(icon); }
function getNodeLabel(n) {
const div = $('<div>',{class:"red-ui-node-list-item"});
const icon = RED.utils.createNodeIcon(n).appendTo(div);
$('<div>',{class:"red-ui-node-label"}).text(getNodePaletteLabel(n)).appendTo(icon);
return div; return div;
} }