* New concept of 'actionKeys' replacing broken 'submit' stuff -- WIP, currently broken but should be quick fix soon

This commit is contained in:
Bryan Ashby 2015-07-09 23:23:37 -06:00
parent 696e4157d9
commit 0d2d2602cd
4 changed files with 140 additions and 30 deletions

View File

@ -1052,7 +1052,7 @@ MultiLineEditTextView.prototype.setText = function(text) {
//this.textLines = [ { text : '' } ];
//this.insertRawText('');
//text = "Tab:\r\n\tA\tB\tC\tD\tE\tF\tG\r\n reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeally long word!!!";
text = require('fs').readFileSync('/home/bashby/Downloads/test_text.txt', { encoding : 'utf-8'});
text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
this.insertRawText(text);//, 0, 0);
this.cursorEndOfDocument();

View File

@ -33,7 +33,9 @@ function ViewController(options) {
this.views = {}; // map of ID -> view
this.formId = options.formId || 0;
this.mciViewFactory = new MCIViewFactory(this.client);
this.submitKeyMap = {};
//this.submitKeyMap = {};
this.actionKeyMap = {};
this.clientKeyPressHandler = function(ch, key) {
//
@ -41,12 +43,32 @@ function ViewController(options) {
// Everything else is forwarded on to the focused View, if any.
//
if(key) {
var actionForKey = self.actionKeyMap[key.name];
if(actionForKey) {
if(_.isNumber(actionForKey)) {
//
// Key works on behalf of a view -- switch focus & submit
//
self.switchFocus(actionForKey);
self.submitForm();
} else if(_.isString(actionForKey)) {
// :TODO: Populate formData here?
// :TODO: Populate actionBlock here -- that is, the actionKey entry... or
// really we just need |extraArgs| to be present, if any
menuUtil.handleAction(self.client, { }, { action : actionForKey } );
}
return;
}
/*
var submitViewId = self.submitKeyMap[key.name];
if(submitViewId) {
self.switchFocus(submitViewId);
self.submitForm();
return;
}
*/
}
if(self.focusedView && self.focusedView.acceptsInput) {
@ -171,6 +193,7 @@ function ViewController(options) {
initialFocusId = viewId;
}
/*
if(view.submit) {
submitId = viewId;
@ -180,6 +203,7 @@ function ViewController(options) {
}
}
}
*/
nextItem(null);
},
@ -451,7 +475,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
if(_.isObject(formConfig)) {
menuUtil.applyThemeCustomization({
name : self.client.currentMenuModule.menuName,
type : "menus",
type : 'menus',
client : self.client,
configMci : formConfig.mci,
});
@ -508,6 +532,43 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
callback(null);
},
function loadActionKeys(callback) {
if(!_.isObject(formConfig) || !_.isArray(formConfig.actionKeys)) {
callback(null);
return;
}
var actionKeyEntry;
formConfig.actionKeys.forEach(function akEntry(ak) {
//
// * 'keys' must be present and be an array of key names
// * If 'viewId' is present, key(s) will focus & submit on behalf
// of the specified view.
// * If 'action' is present, that action will be procesed when
// triggered by key(s)
//
// Ultimately, we'll create a map of key -> { viewId | action }
//
// :TODO: allow for args to be passed along with action as well...
if(!_.isArray(ak.keys)) {
return;
}
if(_.isNumber(ak.viewId)) {
actionKeyEntry = ak.viewId;
} else if(_.isString(ak.action)) {
actionKeyEntry = ak.action;
} else {
return;
}
ak.keys.forEach(function actionKeyName(kn) {
self.actionKeyMap[kn] = actionKeyEntry;
});
});
callback(null);
},
function drawAllViews(callback) {
self.redrawAll(initialFocusId);
callback(null);

View File

@ -33,14 +33,14 @@ function FullScreenEditorModule(options) {
return 'footer' + _.capitalize(editorMode); // e.g.. 'footerEditMenu'
};
this.getFormId = function(whatFor) {
this.getFormId = function(name) {
return {
header : 0,
body : 1,
footerEdit : 2,
footerEditMenu : 3,
fotoerView : 4,
}[whatFor];
}[name];
};
this.redrawFooter = function(options, cb) {
@ -252,10 +252,8 @@ function FullScreenEditorModule(options) {
self.observeEditEvents();
},
editModeEscPressed : function(formData, extraArgs) {
console.log('editorModeBefore=' + self.editorMode)
self.editorMode = 'edit' === self.editorMode ? 'editMenu' : 'edit';
console.log('editorModeAfter=' + self.editorMode)
//self.editorMode = 'editMenu';
self.switchFooter(function next(err) {
if(err) {
// :TODO:... what now?
@ -282,7 +280,7 @@ function FullScreenEditorModule(options) {
});
},
editModeMenu : function(formData, extraArgs) {
console.log('menu 1')
console.log('menu ' + formData.value['1'])
}
};
}

View File

@ -290,8 +290,7 @@
},
"BT5" : {
"width" : 8,
"text" : "< Back",
"submit" : [ "escape" ]
"text" : "< Back"
}
},
"submit" : {
@ -301,7 +300,13 @@
"action" : "@menu:demoMain"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 5
}
]
}
}
}
@ -325,8 +330,7 @@
"hotKeys" : { "Y" : 0, "N" : 1 }
},
"BT8" : {
"text" : "< Back",
"submit" : [ "escape" ]
"text" : "< Back"
}
},
"submit" : {
@ -336,7 +340,13 @@
"action" : "@menu:demoMain"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 8
}
]
}
}
}
@ -354,8 +364,7 @@
"styleSGR2" : "|00|45|01"
},
"BT5" : {
"text" : "< Back",
"submit" : [ "escape" ]
"text" : "< Back"
}
},
"submit" : {
@ -365,7 +374,13 @@
"action" : "@menu:demoMain"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 5
}
]
}
}
}
@ -385,8 +400,7 @@
"focus" : true
},
"BT5" : {
"text" : "< Back",
"submit" : [ "escape" ]
"text" : "< Back"
}
},
"submit" : {
@ -396,7 +410,13 @@
"action" : "@menu:demoMain"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 5
}
]
}
}
}
@ -417,8 +437,7 @@
"hotKeys" : { "U" : 0, "D" : 1, "T" : 2 }
},
"BT5" : {
"text" : "< Back",
"submit" : [ "escape" ]
"text" : "< Back"
}
},
"submit" : {
@ -428,7 +447,13 @@
"action" : "@menu:demoMain"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 5
}
]
}
}
}
@ -515,8 +540,7 @@
"MT1" : {
"width" : 79,
"height" : 17,
"text" : "", // :TODO: should not be req.
"submit" : [ "escape" ]
"text" : "" // :TODO: should not be req.
}
},
"submit" : {
@ -526,7 +550,13 @@
"action" : "@method:editModeEscPressed"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 1
}
]
}
},
"2" : {
@ -545,8 +575,7 @@
"HM1" : {
"mci" : {
"HM1" : {
"items" : [ "Menu 1", "Menu 2", "Menu 3", "Menu 4" ],
"submit" : [ "escape" ]
"items" : [ "Menu 1", "Menu 2", "Menu 3", "Menu 4" ]
}
},
"submit" : {
@ -555,12 +584,34 @@
"value" : { "1" : 0 },
"action" : "@method:editModeMenu"
},
{
"value" : { "1" : 1 },
"action" : "@method:editModeMenu"
},
{
"value" : { "1" : 2 },
"action" : "@method:editModeMenu"
},
{
"value" : { "1" : 3 },
"action" : "@method:editModeMenu"
},
{
"value" : 1,
"action" : "@method:editModeEscPressed"
}
]
}
},
//
// :TODO: concept to replace "submit" per view
// existing submit would remain only as boolean
// ...need general way to override keys for a view -- submit, next, etc.
"actionKeys" : [ // :TODO: Need better name
{
"keys" : [ "escape" ],
"action" : "@method:editModeEscPressed"
}
]
}
}
}