mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-24 11:38:27 +02:00
Resolve: System methods prev/nextArea, and prev/nextConf can cause a crash #79
This commit is contained in:
parent
fb737357f5
commit
0a629feeb0
16 changed files with 376 additions and 353 deletions
73
core/fse.js
73
core/fse.js
|
@ -5,7 +5,6 @@ const MenuModule = require('../core/menu_module.js').MenuModule;
|
|||
const ViewController = require('../core/view_controller.js').ViewController;
|
||||
const ansi = require('../core/ansi_term.js');
|
||||
const theme = require('../core/theme.js');
|
||||
const MultiLineEditTextView = require('../core/multi_line_edit_text_view.js').MultiLineEditTextView;
|
||||
const Message = require('../core/message.js');
|
||||
const getMessageAreaByTag = require('../core/message_area.js').getMessageAreaByTag;
|
||||
const updateMessageAreaLastReadId = require('../core/message_area.js').updateMessageAreaLastReadId;
|
||||
|
@ -694,14 +693,16 @@ function FullScreenEditorModule(options) {
|
|||
setFooterText(MCICodeIds.ViewModeFooter.MsgTotal, self.messageTotal.toString());
|
||||
};
|
||||
|
||||
this.displayHelp = function() {
|
||||
this.displayHelp = function(cb) {
|
||||
self.client.term.rawWrite(ansi.resetScreen());
|
||||
|
||||
theme.displayThemeArt( { name : self.menuConfig.config.art.help, client : self.client },
|
||||
function helpDisplayed(err, artData) {
|
||||
self.client.waitForKeyPress(function keyPress(ch, key) {
|
||||
self.redrawScreen(function redrawn(err) {
|
||||
theme.displayThemeArt(
|
||||
{ name : self.menuConfig.config.art.help, client : self.client },
|
||||
() => {
|
||||
self.client.waitForKeyPress( () => {
|
||||
self.redrawScreen( () => {
|
||||
self.viewControllers[self.getFooterName()].setFocus(true);
|
||||
return cb(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -867,10 +868,11 @@ function FullScreenEditorModule(options) {
|
|||
cb(newFocusViewId);
|
||||
},
|
||||
|
||||
headerSubmit : function(formData, extraArgs) {
|
||||
headerSubmit : function(formData, extraArgs, cb) {
|
||||
self.switchToBody();
|
||||
return cb(null);
|
||||
},
|
||||
editModeEscPressed : function(formData, extraArgs) {
|
||||
editModeEscPressed : function(formData, extraArgs, cb) {
|
||||
self.footerMode = 'editor' === self.footerMode ? 'editorMenu' : 'editor';
|
||||
|
||||
self.switchFooter(function next(err) {
|
||||
|
@ -879,38 +881,40 @@ function FullScreenEditorModule(options) {
|
|||
console.log(err)
|
||||
} else {
|
||||
switch(self.footerMode) {
|
||||
case 'editor' :
|
||||
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
||||
//self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.detachClientEvents();
|
||||
}
|
||||
self.viewControllers.body.switchFocus(1);
|
||||
self.observeEditorEvents();
|
||||
break;
|
||||
case 'editor' :
|
||||
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
||||
//self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.detachClientEvents();
|
||||
}
|
||||
self.viewControllers.body.switchFocus(1);
|
||||
self.observeEditorEvents();
|
||||
break;
|
||||
|
||||
case 'editorMenu' :
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.switchFocus(1);
|
||||
break;
|
||||
case 'editorMenu' :
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.switchFocus(1);
|
||||
break;
|
||||
|
||||
default : throw new Error('Unexpected mode');
|
||||
default : throw new Error('Unexpected mode');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return cb(null);
|
||||
});
|
||||
},
|
||||
editModeMenuQuote : function(formData, extraArgs) {
|
||||
editModeMenuQuote : function(formData, extraArgs, cb) {
|
||||
self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.displayQuoteBuilder();
|
||||
return cb(null);
|
||||
},
|
||||
appendQuoteEntry: function(formData, extraArgs) {
|
||||
appendQuoteEntry: function(formData, extraArgs, cb) {
|
||||
// :TODO: Dont' use magic # ID's here
|
||||
var quoteMsgView = self.viewControllers.quoteBuilder.getView(1);
|
||||
|
||||
if(self.newQuoteBlock) {
|
||||
self.newQuoteBlock = false;
|
||||
|
||||
// :TODO: Make date/time format avail as FSE config
|
||||
// :TODO: Make date/time format avail as FSE config -- also the line itself!
|
||||
var dtFormat = self.client.currentTheme.helpers.getDateTimeFormat();
|
||||
quoteMsgView.addText(
|
||||
'On {0} {1} said...'.format(
|
||||
|
@ -932,9 +936,12 @@ function FullScreenEditorModule(options) {
|
|||
} else {
|
||||
self.quoteBuilderFinalize();
|
||||
}
|
||||
|
||||
return cb(null);
|
||||
},
|
||||
quoteBuilderEscPressed : function(formData, extraArgs) {
|
||||
quoteBuilderEscPressed : function(formData, extraArgs, cb) {
|
||||
self.quoteBuilderFinalize();
|
||||
return cb(null);
|
||||
},
|
||||
/*
|
||||
replyDiscard : function(formData, extraArgs) {
|
||||
|
@ -943,22 +950,16 @@ function FullScreenEditorModule(options) {
|
|||
self.prevMenu();
|
||||
},
|
||||
*/
|
||||
editModeMenuHelp : function(formData, extraArgs) {
|
||||
editModeMenuHelp : function(formData, extraArgs, cb) {
|
||||
self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.displayHelp();
|
||||
return self.displayHelp(cb);
|
||||
},
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// View Mode
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
viewModeEscPressed : function(formData, extraArgs) {
|
||||
//
|
||||
// MLTEV won't get key events -- we need to handle them all here?
|
||||
// ...up/down, page up/page down... both should go by pages
|
||||
// ...Next/Prev/Etc. here
|
||||
},
|
||||
viewModeMenuHelp : function(formData, extraArgs) {
|
||||
viewModeMenuHelp : function(formData, extraArgs, cb) {
|
||||
self.viewControllers.footerView.setFocus(false);
|
||||
self.displayHelp();
|
||||
return self.displayHelp(cb);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -125,17 +125,21 @@ function MenuModule(options) {
|
|||
} else {
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
function finishAndNext(callback) {
|
||||
self.finishedLoading();
|
||||
|
||||
self.autoNextMenu(callback);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
if(err) {
|
||||
console.log(err)
|
||||
// :TODO: what to do exactly?????
|
||||
return self.prevMenu();
|
||||
return self.prevMenu( () => {
|
||||
// dummy
|
||||
});
|
||||
}
|
||||
|
||||
self.finishedLoading();
|
||||
self.autoNextMenu();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -148,16 +152,16 @@ function MenuModule(options) {
|
|||
return _.isNumber(self.menuConfig.options.nextTimeout);
|
||||
};
|
||||
|
||||
this.autoNextMenu = function() {
|
||||
this.autoNextMenu = function(cb) {
|
||||
function goNext() {
|
||||
if(_.isString(self.menuConfig.next) || _.isArray(self.menuConfig.next)) {
|
||||
menuUtil.handleNext(self.client, self.menuConfig.next);
|
||||
return menuUtil.handleNext(self.client, self.menuConfig.next, {}, cb);
|
||||
} else {
|
||||
self.prevMenu();
|
||||
return self.prevMenu(cb);
|
||||
}
|
||||
}
|
||||
|
||||
if(_.has(self.menuConfig, 'runtime.autoNext') && true === self.menuConfig.runtime.autoNext) {
|
||||
if(_.has(self.menuConfig, 'runtime.autoNext') && true === self.menuConfig.runtime.autoNext) {
|
||||
/*
|
||||
If 'next' is supplied, we'll use it. Otherwise, utlize fallback which
|
||||
may be explicit (supplied) or non-explicit (previous menu)
|
||||
|
@ -175,8 +179,8 @@ function MenuModule(options) {
|
|||
}
|
||||
*/
|
||||
if(self.hasNextTimeout()) {
|
||||
setTimeout(function nextTimeout() {
|
||||
goNext();
|
||||
setTimeout( () => {
|
||||
return goNext();
|
||||
}, this.menuConfig.options.nextTimeout);
|
||||
} else {
|
||||
goNext();
|
||||
|
@ -208,7 +212,7 @@ MenuModule.prototype.getSaveState = function() {
|
|||
// nothing in base
|
||||
};
|
||||
|
||||
MenuModule.prototype.restoreSavedState = function(savedState) {
|
||||
MenuModule.prototype.restoreSavedState = function(/*savedState*/) {
|
||||
// nothing in base
|
||||
};
|
||||
|
||||
|
@ -217,20 +221,9 @@ MenuModule.prototype.nextMenu = function(cb) {
|
|||
// If we don't actually have |next|, we'll go previous
|
||||
//
|
||||
if(!this.haveNext()) {
|
||||
this.prevMenu(cb);
|
||||
return;
|
||||
}
|
||||
|
||||
// :TODO: this, prevMenu(), and gotoMenu() need a default |cb| handler if none is supplied.
|
||||
// ...if the error is that we do not meet ACS requirements and did not get a match, then what?
|
||||
if(!cb) {
|
||||
cb = function(err) {
|
||||
if(err) {
|
||||
// :TODO: Don't console.log() here!
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
return this.prevMenu(cb);
|
||||
}
|
||||
|
||||
this.client.menuStack.next(cb);
|
||||
};
|
||||
|
||||
|
|
|
@ -171,10 +171,6 @@ function handleAction(client, formData, conf, cb) {
|
|||
assert(_.isObject(conf));
|
||||
assert(_.isString(conf.action));
|
||||
|
||||
cb = function() {
|
||||
// nothing -- remove me!
|
||||
};
|
||||
|
||||
const actionAsset = asset.parseAsset(conf.action);
|
||||
assert(_.isObject(actionAsset));
|
||||
|
||||
|
|
|
@ -20,26 +20,25 @@ exports.nextConf = nextConf;
|
|||
exports.prevArea = prevArea;
|
||||
exports.nextArea = nextArea;
|
||||
|
||||
function login(callingMenu, formData) {
|
||||
function login(callingMenu, formData, extraArgs, cb) {
|
||||
|
||||
userLogin(callingMenu.client, formData.value.username, formData.value.password, err => {
|
||||
if(err) {
|
||||
// login failure
|
||||
if(err.existingConn && _.has(callingMenu, 'menuConfig.config.tooNodeMenu')) {
|
||||
callingMenu.gotoMenu(callingMenu.menuConfig.config.tooNodeMenu);
|
||||
return callingMenu.gotoMenu(callingMenu.menuConfig.config.tooNodeMenu, cb);
|
||||
} else {
|
||||
// Other error
|
||||
callingMenu.prevMenu();
|
||||
return callingMenu.prevMenu(cb);
|
||||
}
|
||||
|
||||
} else {
|
||||
// success!
|
||||
callingMenu.nextMenu();
|
||||
}
|
||||
|
||||
// success!
|
||||
return callingMenu.nextMenu(cb);
|
||||
});
|
||||
}
|
||||
|
||||
function logoff(callingMenu) {
|
||||
function logoff(callingMenu, formData, extraArgs, cb) {
|
||||
//
|
||||
// Simple logoff. Note that recording of @ logoff properties/stats
|
||||
// occurs elsewhere!
|
||||
|
@ -56,49 +55,52 @@ function logoff(callingMenu) {
|
|||
'NO CARRIER', null, () => {
|
||||
|
||||
// after data is written, disconnect & remove the client
|
||||
return removeClient(client);
|
||||
removeClient(client);
|
||||
return cb(null);
|
||||
}
|
||||
);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function prevMenu(callingMenu) {
|
||||
function prevMenu(callingMenu, formData, extraArgs, cb) {
|
||||
callingMenu.prevMenu( err => {
|
||||
if(err) {
|
||||
callingMenu.client.log.error( { error : err.toString() }, 'Error attempting to fallback!');
|
||||
callingMenu.client.log.error( { error : err.toString() }, 'Error attempting to fallback!');
|
||||
}
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
|
||||
function nextMenu(callingMenu) {
|
||||
function nextMenu(callingMenu, formData, extraArgs, cb) {
|
||||
callingMenu.nextMenu( err => {
|
||||
if(err) {
|
||||
callingMenu.client.log.error( { error : err.toString() }, 'Error attempting to go to next menu!');
|
||||
}
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
|
||||
// :TODO: prev/nextConf, prev/nextArea should use a NYI MenuModule.redraw() or such -- avoid pop/goto() hack!
|
||||
function reloadMenu(menu) {
|
||||
function reloadMenu(menu, cb) {
|
||||
const prevMenu = menu.client.menuStack.pop();
|
||||
prevMenu.instance.leave();
|
||||
menu.client.menuStack.goto(prevMenu.name);
|
||||
menu.client.menuStack.goto(prevMenu.name, cb);
|
||||
}
|
||||
|
||||
function prevConf(callingMenu) {
|
||||
function prevConf(callingMenu, formData, extraArgs, cb) {
|
||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||
const currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag) || confs.length;
|
||||
|
||||
messageArea.changeMessageConference(callingMenu.client, confs[currIndex - 1].confTag, err => {
|
||||
if(err) {
|
||||
return; // logged within changeMessageConference()
|
||||
return cb(err); // logged within changeMessageConference()
|
||||
}
|
||||
|
||||
reloadMenu(callingMenu);
|
||||
return reloadMenu(callingMenu, cb);
|
||||
});
|
||||
}
|
||||
|
||||
function nextConf(callingMenu) {
|
||||
function nextConf(callingMenu, formData, extraArgs, cb) {
|
||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||
let currIndex = confs.findIndex( e => e.confTag === callingMenu.client.user.properties.message_conf_tag);
|
||||
|
||||
|
@ -108,27 +110,27 @@ function nextConf(callingMenu) {
|
|||
|
||||
messageArea.changeMessageConference(callingMenu.client, confs[currIndex + 1].confTag, err => {
|
||||
if(err) {
|
||||
return; // logged within changeMessageConference()
|
||||
return cb(err); // logged within changeMessageConference()
|
||||
}
|
||||
|
||||
reloadMenu(callingMenu);
|
||||
return reloadMenu(callingMenu, cb);
|
||||
});
|
||||
}
|
||||
|
||||
function prevArea(callingMenu) {
|
||||
function prevArea(callingMenu, formData, extraArgs, cb) {
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||
const currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag) || areas.length;
|
||||
|
||||
messageArea.changeMessageArea(callingMenu.client, areas[currIndex - 1].areaTag, err => {
|
||||
if(err) {
|
||||
return; // logged within changeMessageArea()
|
||||
return cb(err); // logged within changeMessageArea()
|
||||
}
|
||||
|
||||
reloadMenu(callingMenu);
|
||||
return reloadMenu(callingMenu, cb);
|
||||
});
|
||||
}
|
||||
|
||||
function nextArea(callingMenu) {
|
||||
function nextArea(callingMenu, formData, extraArgs, cb) {
|
||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||
let currIndex = areas.findIndex( e => e.areaTag === callingMenu.client.user.properties.message_area_tag);
|
||||
|
||||
|
@ -138,9 +140,9 @@ function nextArea(callingMenu) {
|
|||
|
||||
messageArea.changeMessageArea(callingMenu.client, areas[currIndex + 1].areaTag, err => {
|
||||
if(err) {
|
||||
return; // logged within changeMessageArea()
|
||||
return cb(err); // logged within changeMessageArea()
|
||||
}
|
||||
|
||||
reloadMenu(callingMenu);
|
||||
return reloadMenu(callingMenu, cb);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -106,10 +106,13 @@ function UserConfigModule(options) {
|
|||
cb(newFocusId);
|
||||
},
|
||||
|
||||
saveChanges : function(formData, extraArgs) {
|
||||
//
|
||||
// Handlers
|
||||
//
|
||||
saveChanges : function(formData, extraArgs, cb) {
|
||||
assert(formData.value.password === formData.value.passwordConfirm);
|
||||
|
||||
var newProperties = {
|
||||
const newProperties = {
|
||||
real_name : formData.value.realName,
|
||||
birthdate : new Date(Date.parse(formData.value.birthdate)).toISOString(),
|
||||
sex : formData.value.sex,
|
||||
|
@ -122,33 +125,31 @@ function UserConfigModule(options) {
|
|||
};
|
||||
|
||||
// runtime set theme
|
||||
theme.setClientTheme(self.client, newProperties.theme_id);
|
||||
theme.setClientTheme(self.client, newProperties.theme_id);
|
||||
|
||||
// persist all changes
|
||||
self.client.user.persistProperties(newProperties, function persisted(err) {
|
||||
self.client.user.persistProperties(newProperties, err => {
|
||||
if(err) {
|
||||
self.client.log.warn( { error : err.toString() }, 'Failed persisting updated properties');
|
||||
// :TODO: warn end user!
|
||||
self.prevMenu();
|
||||
return self.prevMenu(cb);
|
||||
}
|
||||
//
|
||||
// New password if it's not empty
|
||||
//
|
||||
self.client.log.info('User updated properties');
|
||||
|
||||
if(formData.value.password.length > 0) {
|
||||
self.client.user.setNewAuthCredentials(formData.value.password, err => {
|
||||
if(err) {
|
||||
self.client.log.error( { err : err }, 'Failed storing new authentication credentials');
|
||||
} else {
|
||||
self.client.log.info('User changed authentication credentials');
|
||||
}
|
||||
return self.prevMenu(cb);
|
||||
});
|
||||
} else {
|
||||
//
|
||||
// New password if it's not empty
|
||||
//
|
||||
self.client.log.info('User updated properties');
|
||||
|
||||
if(formData.value.password.length > 0) {
|
||||
self.client.user.setNewAuthCredentials(formData.value.password, function newAuthStored(err) {
|
||||
if(err) {
|
||||
// :TODO: warn the end user!
|
||||
self.client.log.warn( { error : err.toString() }, 'Failed storing new authentication credentials');
|
||||
} else {
|
||||
self.client.log.info('User changed authentication credentials');
|
||||
}
|
||||
self.prevMenu();
|
||||
});
|
||||
} else {
|
||||
self.prevMenu();
|
||||
}
|
||||
return self.prevMenu(cb);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
// ENiGMA½
|
||||
var MCIViewFactory = require('./mci_view_factory.js').MCIViewFactory;
|
||||
var menuUtil = require('./menu_util.js');
|
||||
//var Log = require('./logger.js').log;
|
||||
var Config = require('./config.js').config;
|
||||
var asset = require('./asset.js');
|
||||
var ansi = require('./ansi_term.js');
|
||||
|
||||
// deps
|
||||
var events = require('events');
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
|
@ -37,6 +36,26 @@ function ViewController(options) {
|
|||
|
||||
this.actionKeyMap = {};
|
||||
|
||||
//
|
||||
// Small wrapper/proxy around handleAction() to ensure we do not allow
|
||||
// input/additional actions queued while performing an action
|
||||
//
|
||||
this.handleActionWrapper = function(formData, actionBlock) {
|
||||
if(self.waitActionCompletion) {
|
||||
return; // ignore until this is finished!
|
||||
}
|
||||
|
||||
self.waitActionCompletion = true;
|
||||
menuUtil.handleAction(self.client, formData, actionBlock, (err) => {
|
||||
if(err) {
|
||||
// :TODO: What can we really do here?
|
||||
self.client.log.warn( { err : err }, 'Error during handleAction()');
|
||||
}
|
||||
|
||||
self.waitActionCompletion = false;
|
||||
});
|
||||
};
|
||||
|
||||
this.clientKeyPressHandler = function(ch, key) {
|
||||
//
|
||||
// Process key presses treating form submit mapped keys special.
|
||||
|
@ -51,10 +70,9 @@ function ViewController(options) {
|
|||
self.switchFocus(actionForKey.viewId);
|
||||
self.submitForm(key);
|
||||
} else if(_.isString(actionForKey.action)) {
|
||||
menuUtil.handleAction(
|
||||
self.client,
|
||||
{ ch : ch, key : key }, // formData
|
||||
actionForKey); // action block
|
||||
self.handleActionWrapper(
|
||||
{ ch : ch, key : key }, // formData
|
||||
actionForKey); // actionBlock
|
||||
}
|
||||
} else {
|
||||
if(self.focusedView && self.focusedView.acceptsInput) {
|
||||
|
@ -65,28 +83,28 @@ function ViewController(options) {
|
|||
|
||||
this.viewActionListener = function(action, key) {
|
||||
switch(action) {
|
||||
case 'next' :
|
||||
self.emit('action', { view : this, action : action, key : key });
|
||||
self.nextFocus();
|
||||
break;
|
||||
case 'next' :
|
||||
self.emit('action', { view : this, action : action, key : key });
|
||||
self.nextFocus();
|
||||
break;
|
||||
|
||||
case 'accept' :
|
||||
if(self.focusedView && self.focusedView.submit) {
|
||||
// :TODO: need to do validation here!!!
|
||||
var focusedView = self.focusedView;
|
||||
self.validateView(focusedView, function validated(err, newFocusedViewId) {
|
||||
if(err) {
|
||||
var newFocusedView = self.getView(newFocusedViewId) || focusedView;
|
||||
self.setViewFocusWithEvents(newFocusedView, true);
|
||||
} else {
|
||||
self.submitForm(key);
|
||||
}
|
||||
});
|
||||
//self.submitForm(key);
|
||||
} else {
|
||||
self.nextFocus();
|
||||
}
|
||||
break;
|
||||
case 'accept' :
|
||||
if(self.focusedView && self.focusedView.submit) {
|
||||
// :TODO: need to do validation here!!!
|
||||
var focusedView = self.focusedView;
|
||||
self.validateView(focusedView, function validated(err, newFocusedViewId) {
|
||||
if(err) {
|
||||
var newFocusedView = self.getView(newFocusedViewId) || focusedView;
|
||||
self.setViewFocusWithEvents(newFocusedView, true);
|
||||
} else {
|
||||
self.submitForm(key);
|
||||
}
|
||||
});
|
||||
//self.submitForm(key);
|
||||
} else {
|
||||
self.nextFocus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -159,48 +177,48 @@ function ViewController(options) {
|
|||
propAsset = asset.getViewPropertyAsset(conf[propName]);
|
||||
if(propAsset) {
|
||||
switch(propAsset.type) {
|
||||
case 'config' :
|
||||
propValue = asset.resolveConfigAsset(conf[propName]);
|
||||
break;
|
||||
case 'config' :
|
||||
propValue = asset.resolveConfigAsset(conf[propName]);
|
||||
break;
|
||||
|
||||
// :TODO: handle @art (e.g. text : @art ...)
|
||||
// :TODO: handle @art (e.g. text : @art ...)
|
||||
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if('validate' === propName) {
|
||||
// :TODO: handle propAsset.location for @method script specification
|
||||
if('systemMethod' === propAsset.type) {
|
||||
// :TODO: implementation validation @systemMethod handling!
|
||||
var methodModule = require(paths.join(__dirname, 'system_view_validate.js'));
|
||||
if(_.isFunction(methodModule[propAsset.asset])) {
|
||||
propValue = methodModule[propAsset.asset];
|
||||
}
|
||||
} else {
|
||||
if(_.isFunction(self.client.currentMenuModule.menuMethods[propAsset.asset])) {
|
||||
propValue = self.client.currentMenuModule.menuMethods[propAsset.asset];
|
||||
}
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if('validate' === propName) {
|
||||
// :TODO: handle propAsset.location for @method script specification
|
||||
if('systemMethod' === propAsset.type) {
|
||||
// :TODO: implementation validation @systemMethod handling!
|
||||
var methodModule = require(paths.join(__dirname, 'system_view_validate.js'));
|
||||
if(_.isFunction(methodModule[propAsset.asset])) {
|
||||
propValue = methodModule[propAsset.asset];
|
||||
}
|
||||
} else {
|
||||
if(_.isString(propAsset.location)) {
|
||||
if(_.isFunction(self.client.currentMenuModule.menuMethods[propAsset.asset])) {
|
||||
propValue = self.client.currentMenuModule.menuMethods[propAsset.asset];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(_.isString(propAsset.location)) {
|
||||
|
||||
} else {
|
||||
if('systemMethod' === propAsset.type) {
|
||||
// :TODO:
|
||||
} 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);
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
propValue = propValue = conf[propName];
|
||||
break;
|
||||
default :
|
||||
propValue = propValue = conf[propName];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
propValue = conf[propName];
|
||||
|
@ -287,6 +305,13 @@ function ViewController(options) {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
:TODO: support:
|
||||
value: {
|
||||
someArgName: [ "key1", "key2", ... ],
|
||||
someOtherArg: [ "key1, ... ]
|
||||
}
|
||||
*/
|
||||
var actionValueKeys = Object.keys(actionValue);
|
||||
for(var i = 0; i < actionValueKeys.length; ++i) {
|
||||
var viewId = actionValueKeys[i];
|
||||
|
@ -510,11 +535,12 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
|
|||
},
|
||||
function prepareFormSubmission(callback) {
|
||||
if(false === self.noInput) {
|
||||
|
||||
self.on('submit', function promptSubmit(formData) {
|
||||
self.client.log.trace( { formData : self.getLogFriendlyFormData(formData) }, 'Prompt submit');
|
||||
|
||||
if(_.isString(self.client.currentMenuModule.menuConfig.action)) {
|
||||
menuUtil.handleAction(self.client, formData, self.client.currentMenuModule.menuConfig);
|
||||
self.handleActionWrapper(formData, self.client.currentMenuModule.menuConfig);
|
||||
} else {
|
||||
//
|
||||
// Menus that reference prompts can have a sepcial "submit" block without the
|
||||
|
@ -538,7 +564,7 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
|
|||
var actionBlock = menuSubmit[c];
|
||||
|
||||
if(_.isEqual(formData.value, actionBlock.value, self.actionBlockValueComparator)) {
|
||||
menuUtil.handleAction(self.client, formData, actionBlock);
|
||||
self.handleActionWrapper(formData, actionBlock);
|
||||
break; // there an only be one...
|
||||
}
|
||||
}
|
||||
|
@ -666,7 +692,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
|
|||
var actionBlock = confForFormId[c];
|
||||
|
||||
if(_.isEqual(formData.value, actionBlock.value, self.actionBlockValueComparator)) {
|
||||
menuUtil.handleAction(self.client, formData, actionBlock);
|
||||
self.handleActionWrapper(formData, actionBlock);
|
||||
break; // there an only be one...
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue