allow a node's icon to be set dynamically (#1490)

* create a proto type

* Fixed some problems after reviewing
This commit is contained in:
Kazuki Nakanishi
2017-11-30 13:13:35 +00:00
committed by Nick O'Leary
parent cc88ebd2b9
commit 6d2389945b
16 changed files with 367 additions and 19 deletions

View File

@@ -579,6 +579,25 @@ var defaultIcon = path.resolve(__dirname + '/../../../../public/icons/arrow-in.p
function nodeIconDir(dir) {
icon_paths[dir.name] = icon_paths[dir.name] || [];
icon_paths[dir.name].push(path.resolve(dir.path));
if (dir.icons) {
if (!moduleConfigs[dir.name]) {
moduleConfigs[dir.name] = {
name: dir.name,
nodes: {},
icons: []
};
}
var module = moduleConfigs[dir.name];
if (module.icons === undefined) {
module.icons = [];
}
dir.icons.forEach(function(icon) {
if (module.icons.indexOf(icon) === -1) {
module.icons.push(icon);
}
});
}
}
function getNodeIconPath(module,icon) {
@@ -607,6 +626,20 @@ function getNodeIconPath(module,icon) {
}
}
function getNodeIcons() {
var iconList = {};
for (var module in moduleConfigs) {
if (moduleConfigs.hasOwnProperty(module)) {
if (moduleConfigs[module].icons) {
iconList[module] = moduleConfigs[module].icons;
}
}
}
return iconList;
}
var registry = module.exports = {
init: init,
load: load,
@@ -629,6 +662,7 @@ var registry = module.exports = {
getModuleInfo: getModuleInfo,
getNodeIconPath: getNodeIconPath,
getNodeIcons: getNodeIcons,
/**
* Gets all of the node template configs
* @return all of the node templates in a single string