* Quote builder very functional, some bugs

* Work on fallback system (implicit); Added some notes... need saveState/restoreState type functionality as extraArgs may not be final args!
This commit is contained in:
Bryan Ashby 2015-09-17 22:53:19 -06:00
parent 6970e6e2ab
commit 9865da34cc
6 changed files with 112 additions and 23 deletions

View File

@ -395,6 +395,9 @@ function Client(input, output) {
self.detachCurrentMenuModule = function() { self.detachCurrentMenuModule = function() {
if(self.currentMenuModule) { if(self.currentMenuModule) {
self.currentMenuModule.leave(); self.currentMenuModule.leave();
self.lastMenuModuleInfo = self.currentMenuModuleInfo;
self.currentMenuModule = null; self.currentMenuModule = null;
} }
}; };
@ -446,24 +449,22 @@ Client.prototype.gotoMenuModule = function(options, cb) {
extraArgs : options.extraArgs, extraArgs : options.extraArgs,
}; };
menuUtil.loadMenu(loadOptions, function onMenuModuleLoaded(err, modInst) { menuUtil.loadMenu(loadOptions, function menuModuleLoaded(err, modInst) {
if(err) { if(err) {
cb(err); cb(err);
} else { } else {
self.log.debug( { menuName : options.name }, 'Goto menu module'); self.log.debug( { menuName : options.name }, 'Goto menu module');
if(self.currentMenuModule) { self.currentMenuModule = modInst; // :TODO: should probably be before enter() above
self.lastMenuModuleInfo = {
name : self.currentMenuModule.modInfo.name, self.currentMenuModuleInfo = {
extraArgs : self.currentMenuModuleExtraArgs, // :TODO: This is quite the hack... doesn't seem right...
}; menuName : self.currentMenuModule.menuName,
extraArgs : options.extraArgs,
} }
modInst.enter(self); modInst.enter(self);
self.currentMenuModule = modInst; // :TODO: should probably be before enter() above
self.currentMenuModuleExtraArgs = options.extraArgs;
if(!callbackOnErrorOnly) { if(!callbackOnErrorOnly) {
cb(null); cb(null);
} }
@ -476,11 +477,13 @@ Client.prototype.fallbackMenuModule = function(cb) {
if(self.lastMenuModuleInfo) { if(self.lastMenuModuleInfo) {
var modOpts = { var modOpts = {
name : self.lastMenuModuleInfo.name, name : self.lastMenuModuleInfo.menuName,
extraArgs : self.lastMenuModuleInfo.extraArgs, extraArgs : self.lastMenuModuleInfo.extraArgs,
}; };
self.gotoMenuModule(modOpts, cb); self.gotoMenuModule(modOpts, cb);
} else {
cb(new Error('Nothing to fallback to!'));
} }
}; };

View File

@ -655,6 +655,19 @@ function FullScreenEditorModule(options) {
self.viewControllers[self.getFooterName()].switchFocus(1); // HM1 self.viewControllers[self.getFooterName()].switchFocus(1); // HM1
}; };
this.switchFromQuoteBuilderToBody = function() {
self.viewControllers.quoteBuilder.setFocus(false);
var body = self.viewControllers.body.getView(1);
body.redraw();
self.viewControllers.body.switchFocus(1);
// :TODO: create method (DRY)
self.updateTextEditMode(body.getTextEditMode());
self.updateEditModePosition(body.getEditPosition());
self.observeEditorEvents();
}
this.menuMethods = { this.menuMethods = {
// :TODO: rename to editModeHeaderSubmit // :TODO: rename to editModeHeaderSubmit
@ -700,6 +713,7 @@ function FullScreenEditorModule(options) {
if(self.newQuoteBlock) { if(self.newQuoteBlock) {
self.newQuoteBlock = false; self.newQuoteBlock = false;
// :TODO: Make date/time format avail as FSE config
var dtFormat = self.client.currentTheme.helpers.getDateTimeFormat(); var dtFormat = self.client.currentTheme.helpers.getDateTimeFormat();
quoteMsgView.addText( quoteMsgView.addText(
'On {0} {1} said...'.format( 'On {0} {1} said...'.format(
@ -711,7 +725,7 @@ function FullScreenEditorModule(options) {
var quoteText = self.viewControllers.quoteBuilder.getView(3).getItem(formData.value.quote); var quoteText = self.viewControllers.quoteBuilder.getView(3).getItem(formData.value.quote);
quoteMsgView.addText(quoteText); quoteMsgView.addText(quoteText);
// :TODO: Menus need a setFocusIndex() call -- move down to next item here self.viewControllers.quoteBuilder.getView(3).focusNext();
}, },
quoteBuilderEscPressed : function(formData, extraArgs) { quoteBuilderEscPressed : function(formData, extraArgs) {
// :TODO: fix magic #'s // :TODO: fix magic #'s
@ -727,12 +741,16 @@ function FullScreenEditorModule(options) {
//self.redrawFooter( { clear : true, footerName : footerName }, function footerDisplayed(err) { //self.redrawFooter( { clear : true, footerName : footerName }, function footerDisplayed(err) {
self.footerMode = 'editor'; self.footerMode = 'editor';
self.switchFooter(function switched(err) { self.switchFooter(function switched(err) {
self.viewControllers.quoteBuilder.setFocus(false); self.switchFromQuoteBuilderToBody();
self.viewControllers.body.redrawAll(); });
self.viewControllers[footerName].redrawAll(); },
self.viewControllers.body.switchFocus(1); replyDiscard : function(formData, extraArgs) {
// :TODO: need to prompt yes/no
// :TODO: @method for fallback would be better
self.client.fallbackMenuModule(function fallback(err) {
console.log(err)
}); });
}, },
editModeMenuHelp : function(formData, extraArgs) { editModeMenuHelp : function(formData, extraArgs) {

View File

@ -110,7 +110,7 @@ function loadMenu(options, cb) {
{ {
menuName : options.name, menuName : options.name,
menuConfig : modData.config, menuConfig : modData.config,
extraArgs : options.extraArgs, extraArgs : options.extraArgs
}); });
callback(null, moduleInstance); callback(null, moduleInstance);
} catch(e) { } catch(e) {

View File

@ -62,6 +62,14 @@ MenuView.prototype.getItem = function(index) {
return this.items[index].text; return this.items[index].text;
}; };
MenuView.prototype.focusNext = function() {
// nothing @ base currently
};
MenuView.prototype.focusPrevious = function() {
// nothign @ base currently
};
MenuView.prototype.setFocusItems = function(items) { MenuView.prototype.setFocusItems = function(items) {
var self = this; var self = this;

View File

@ -151,7 +151,9 @@ VerticalMenuView.prototype.onKeyPress = function(ch, key) {
if(key) { if(key) {
var prevFocusedItemIndex = this.focusedItemIndex; var prevFocusedItemIndex = this.focusedItemIndex;
if(this.isKeyMapped('up', key.name)) { if(this.isKeyMapped('up', key.name)) {
this.focusPrevious();
/*
if(0 === this.focusedItemIndex) { if(0 === this.focusedItemIndex) {
this.focusedItemIndex = this.items.length - 1; this.focusedItemIndex = this.items.length - 1;
@ -169,8 +171,9 @@ VerticalMenuView.prototype.onKeyPress = function(ch, key) {
this.viewWindow.bottom--; this.viewWindow.bottom--;
} }
} }
*/
} else if(this.isKeyMapped('down', key.name)) { } else if(this.isKeyMapped('down', key.name)) {
if(this.items.length - 1 === this.focusedItemIndex) { /*if(this.items.length - 1 === this.focusedItemIndex) {
this.focusedItemIndex = 0; this.focusedItemIndex = 0;
this.viewWindow = { this.viewWindow = {
@ -185,11 +188,13 @@ VerticalMenuView.prototype.onKeyPress = function(ch, key) {
this.viewWindow.bottom++; this.viewWindow.bottom++;
} }
} }
*/
this.focusNext();
} }
if(prevFocusedItemIndex !== this.focusedItemIndex) { if(prevFocusedItemIndex !== this.focusedItemIndex) {
// :TODO: Optimize this for cases where no scrolling occured & only two items need updated // :TODO: Optimize this for cases where no scrolling occured & only two items need updated
this.redraw(); // this.redraw();
} }
} }
@ -206,6 +211,54 @@ VerticalMenuView.prototype.setItems = function(items) {
this.positionCacheExpired = true; this.positionCacheExpired = true;
}; };
VerticalMenuView.prototype.focusNext = function() {
VerticalMenuView.super_.prototype.focusNext.call(this);
if(this.items.length - 1 === this.focusedItemIndex) {
this.focusedItemIndex = 0;
this.viewWindow = {
top : 0,
bottom : Math.min(this.focusedItemIndex + this.maxVisibleItems, this.items.length) - 1
};
} else {
this.focusedItemIndex++;
if(this.focusedItemIndex > this.viewWindow.bottom) {
this.viewWindow.top++;
this.viewWindow.bottom++;
}
}
this.redraw();
};
VerticalMenuView.prototype.focusPrevious = function() {
VerticalMenuView.super_.prototype.focusPrevious.call(this);
if(0 === this.focusedItemIndex) {
this.focusedItemIndex = this.items.length - 1;
this.viewWindow = {
//top : this.items.length - this.maxVisibleItems,
top : Math.max(this.items.length - this.maxVisibleItems, 0),
bottom : this.items.length - 1
};
} else {
this.focusedItemIndex--;
if(this.focusedItemIndex < this.viewWindow.top) {
this.viewWindow.top--;
this.viewWindow.bottom--;
}
}
this.redraw();
};
VerticalMenuView.prototype.setFocusItems = function(items) { VerticalMenuView.prototype.setFocusItems = function(items) {
VerticalMenuView.super_.prototype.setFocusItems.call(this, items); VerticalMenuView.super_.prototype.setFocusItems.call(this, items);

View File

@ -570,7 +570,6 @@
} }
}, },
messageAreaReplyPost: { messageAreaReplyPost: {
//module: msg_area_reply_fse
module: msg_area_post_fse module: msg_area_post_fse
config: { config: {
art: { art: {
@ -579,7 +578,8 @@
quote: MSGQUOT quote: MSGQUOT
footerEditor: MSGEFTR footerEditor: MSGEFTR
footerEditorMenu: MSGEMFT footerEditorMenu: MSGEMFT
// :TODO: help // :TODO: fix help
help: demo_fse_netmail_help.ans
} }
editorMode: edit editorMode: edit
editorType: area editorType: area
@ -647,10 +647,18 @@
submit: { submit: {
*: [ *: [
{
value: { 1: 1 }
action: @method:replyDiscard
}
{ {
value: { 1: 2 }, value: { 1: 2 },
action: @method:editModeMenuQuote action: @method:editModeMenuQuote
} }
{
value: { 1: 3 }
action: @method:editModeMenuHelp
}
] ]
} }
@ -670,7 +678,6 @@
height: 7 height: 7
} }
VM3: { VM3: {
//items: [ "just", "testing", "some", "things" ]
width: 79 width: 79
height: 4 height: 4
argName: quote argName: quote