* Added ability to pass a "menu result" from a menu when calling prev()/prevMenu()

* Ability to fully quit newscan with X key using new menu result functionality
This commit is contained in:
Bryan Ashby 2016-08-30 21:31:24 -06:00
parent 48aa0fa606
commit 0a3a62edf3
5 changed files with 35 additions and 9 deletions

View File

@ -318,3 +318,7 @@ MenuModule.prototype.standardMCIReadyHandler = function(mciData, cb) {
MenuModule.prototype.finishedLoading = function() {
};
MenuModule.prototype.getMenuResult = function() {
// nothing in base
};

View File

@ -73,6 +73,8 @@ module.exports = class MenuStack {
}
prev(cb) {
const menuResult = this.top().instance.getMenuResult();
// :TODO: leave() should really take a cb...
this.pop().instance.leave(); // leave & remove current
@ -81,7 +83,8 @@ module.exports = class MenuStack {
if(previousModuleInfo) {
const opts = {
extraArgs : previousModuleInfo.extraArgs,
savedState : previousModuleInfo.savedState
savedState : previousModuleInfo.savedState,
lastMenuResult : menuResult,
};
return this.goto(previousModuleInfo.name, opts, cb);
@ -113,6 +116,7 @@ module.exports = class MenuStack {
if(_.isObject(options)) {
loadOpts.extraArgs = options.extraArgs;
loadOpts.lastMenuResult = options.lastMenuResult;
}
loadMenu(loadOpts, (err, modInst) => {

View File

@ -94,6 +94,7 @@ function loadMenu(options, cb) {
menuConfig : modData.config,
extraArgs : options.extraArgs,
client : options.client,
lastMenuResult : options.lastMenuResult,
});
return callback(null, moduleInstance);
} catch(e) {

View File

@ -37,6 +37,8 @@ function NewScanModule(options) {
var self = this;
var config = this.menuConfig.config;
this.newScanFullExit = _.has(options, 'lastMenuResult.fullExit') ? options.lastMenuResult.fullExit : false;
this.currentStep = 'messageConferences';
this.currentScanAux = {};
@ -191,6 +193,12 @@ NewScanModule.prototype.restoreSavedState = function(savedState) {
NewScanModule.prototype.mciReady = function(mciData, cb) {
if(this.newScanFullExit) {
// user has canceled the entire scan @ message list view
return cb(null);
}
var self = this;
var vc = self.viewControllers.allViews = new ViewController( { client : self.client } );

View File

@ -103,6 +103,11 @@ function MessageListModule(options) {
} else {
return cb(null);
}
},
fullExit : function(formData, extraArgs, cb) {
self.menuResult = { fullExit : true };
return self.prevMenu(cb);
}
};
@ -250,3 +255,7 @@ MessageListModule.prototype.restoreSavedState = function(savedState) {
this.initialFocusIndex = savedState.initialFocusIndex;
}
};
MessageListModule.prototype.getMenuResult = function() {
return this.menuResult;
};