mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-30 22:46:17 +02:00
* @method for view properties. WIP... hacked in, needs cleaned up & DRY
* Messing around with different approaches to last callers...
This commit is contained in:
parent
542327460b
commit
99ea870ebc
8 changed files with 337 additions and 17 deletions
|
@ -131,9 +131,26 @@ function ViewController(options) {
|
|||
|
||||
// :TODO: move this elsewhere
|
||||
this.setViewPropertiesFromMCIConf = function(view, conf) {
|
||||
|
||||
var propAsset;
|
||||
var propValue;
|
||||
|
||||
function callModuleMethod(path) {
|
||||
if('' === paths.extname(path)) {
|
||||
path += '.js';
|
||||
}
|
||||
|
||||
try {
|
||||
var methodMod = require(path);
|
||||
// :TODO: fix formData & extraArgs
|
||||
return methodMod[propAsset.asset](self.client.currentMenuModule, {}, {} );
|
||||
} catch(e) {
|
||||
self.client.log.error( { error : e.toString(), methodName : propAsset.asset }, 'Failed to execute asset method');
|
||||
}
|
||||
}
|
||||
|
||||
for(var propName in conf) {
|
||||
var propValue;
|
||||
var propAsset = asset.getViewPropertyAsset(conf[propName]);
|
||||
propAsset = asset.getViewPropertyAsset(conf[propName]);
|
||||
if(propAsset) {
|
||||
switch(propAsset.type) {
|
||||
case 'config' :
|
||||
|
@ -142,6 +159,42 @@ function ViewController(options) {
|
|||
|
||||
// :TODO: handle @art (e.g. text : @art ...)
|
||||
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(propAsset.location)) {
|
||||
|
||||
} else {
|
||||
if('systemMethod' === propAsset.type) {
|
||||
// :TODO:
|
||||
} else {
|
||||
// local to current module
|
||||
var currentModule = self.client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[propAsset.asset])) {
|
||||
// :TODO: Fix formData & extraArgs... this all needs general processing
|
||||
propValue = currentModule.menuMethods[propAsset.asset]({}, {});//formData, conf.extraArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(actionAsset.location)) {
|
||||
callModuleMenuMethod(paths.join(Config.paths.mods, actionAsset.location));
|
||||
} else {
|
||||
if('systemMethod' === actionAsset.type) {
|
||||
// :TODO: Need to pass optional args here -- conf.extraArgs and args between e.g. ()
|
||||
// :TODO: Probably better as system_method.js
|
||||
callModuleMenuMethod(paths.join(__dirname, 'system_menu_method.js'));
|
||||
} else {
|
||||
// local to current module
|
||||
var currentModule = client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[actionAsset.asset])) {
|
||||
currentModule.menuMethods[actionAsset.asset](formData, conf.extraArgs);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
|
||||
default :
|
||||
propValue = propValue = conf[propName];
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue