+ asset.getModuleAsset()

* Menus can specify built in menu modules: @systemModule:XXXXX
This commit is contained in:
Bryan Ashby 2015-08-08 15:52:47 -06:00
parent b8d4741c18
commit dbb3e04166
4 changed files with 28 additions and 8 deletions

View File

@ -9,6 +9,7 @@ var assert = require('assert');
exports.parseAsset = parseAsset;
exports.getArtAsset = getArtAsset;
exports.getModuleAsset = getModuleAsset;
exports.resolveConfigAsset = resolveConfigAsset;
exports.getViewPropertyAsset = getViewPropertyAsset;
@ -17,6 +18,7 @@ var ALL_ASSETS = [
'menu',
'method',
'systemMethod',
'systemModule',
'prompt',
'config',
];
@ -58,6 +60,24 @@ function getArtAsset(art) {
}
}
function getModuleAsset(module) {
if(!_.isString(module)) {
return null;
}
if('@' === module[0]) {
var modAsset = parseAsset(module);
assert('module' === modAsset.type || 'systemModule' === modAsset.type);
return modAsset;
} else {
return {
type : 'module',
asset : module,
}
}
}
function resolveConfigAsset(from) {
var asset = parseAsset(from);
if(asset) {

View File

@ -81,13 +81,13 @@ function loadMenu(options, cb) {
});
},
function loadMenuModule(menuConfig, callback) {
var modSupplied = _.isString(menuConfig.module);
var modAsset = asset.getModuleAsset(menuConfig.module);
var modSupplied = null !== modAsset;
var modLoadOpts = {
name : modSupplied ? menuConfig.module : 'standard_menu',
path : modSupplied ? Config.paths.mods : __dirname,
category : modSupplied ? 'mods' : null,
name : modSupplied ? modAsset.asset : 'standard_menu',
path : (!modSupplied || 'systemModule' === modAsset.type) ? __dirname : Config.paths.mods,
category : (!modSupplied || 'systemModule' === modAsset.type) ? null : 'mods',
};
moduleUtil.loadModuleEx(modLoadOpts, function moduleLoaded(err, mod) {
@ -99,7 +99,7 @@ function loadMenu(options, cb) {
callback(err, modData);
});
},
},
function createModuleInstance(modData, callback) {
Log.debug(
{ moduleName : modData.name, args : options.args, config : modData.config, info : modData.mod.modInfo },

View File

@ -661,8 +661,8 @@
"options" : { "cls" : true }
},
"demoFullScreenEditor" : {
"module" : "fse",
"art" : "demo_fse_local_user.ans",
"module" : "@systemModule:fse",
//"art" : "demo_fse_local_user.ans",
"options" : { "cls" : true },
"config" : {
"editorType" : "netMail",