Another pass of categorisation

This commit is contained in:
Nick O'Leary
2019-07-09 20:26:26 +01:00
parent 00a3e25714
commit 2b66723d42
19 changed files with 40 additions and 35 deletions

View File

@@ -19,15 +19,15 @@ RED.palette = (function() {
var exclusion = ['config','unknown','deprecated'];
var coreCategories = [
'subflows',
'flow',
'input',
'output',
'common',
'function',
'input/output',
'sequence',
'parser',
'social',
'mobile',
'storage',
'analysis',
'social',
'mobile',
'advanced'
];
@@ -35,6 +35,7 @@ RED.palette = (function() {
var sidebarControls;
function createCategory(originalCategory,rootCategory,category,ns) {
console.log("createCategory",originalCategory,rootCategory,category,ns);
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
}
@@ -44,6 +45,7 @@ RED.palette = (function() {
}
}
function createCategoryContainer(originalCategory,category, labelId) {
console.log("createCategoryContainer",originalCategory,category,labelId);
var label = RED._(labelId, {defaultValue:category});
label = (label || category).replace(/_/g, " ");
var catDiv = $('<div id="red-ui-palette-container-'+category+'" class="red-ui-palette-category hide">'+
@@ -165,6 +167,9 @@ RED.palette = (function() {
return $(".red-ui-palette-node[data-palette-type='"+type+"']");
}
function escapeCategory(category) {
return category.replace(/[ /.]/g,"_");
}
function addNodeType(nt,def) {
if (getPaletteNode(nt).length) {
return;
@@ -172,7 +177,7 @@ RED.palette = (function() {
if (exclusion.indexOf(def.category)===-1) {
var originalCategory = def.category;
var category = def.category.replace(/ /g,"_");
var category = escapeCategory(def.category);
var rootCategory = category.split("-")[0];
var d = $('<div>',{class:"red-ui-palette-node"}).attr("data-palette-type",nt).data('category',rootCategory);
@@ -423,7 +428,7 @@ RED.palette = (function() {
var currentCategory = paletteNode.data('category');
var newCategory = (sf.category||"subflows");
if (currentCategory !== newCategory) {
var category = newCategory.replace(/ /g,"_");
var category = escapeCategory(newCategory);
createCategory(newCategory,category,category,"node-red");
var currentCategoryNode = paletteNode.closest(".red-ui-palette-category");
@@ -556,7 +561,7 @@ RED.palette = (function() {
categoryList = coreCategories
}
categoryList.forEach(function(category){
createCategoryContainer(category, category, "palette.label."+category);
createCategoryContainer(category, escapeCategory(category), "palette.label."+escapeCategory(category));
});