* More work on menu system and form handling. Lots of work to do!

This commit is contained in:
Bryan Ashby 2015-03-30 21:29:06 -06:00
parent d6ffa2b26e
commit 3274908586
7 changed files with 54 additions and 11 deletions

View File

@ -75,6 +75,7 @@ function ANSIEscapeParser(options) {
//self.bgColor = 0; //self.bgColor = 0;
self.fgColor = 39; self.fgColor = 39;
self.bgColor = 49; self.bgColor = 49;
self.flags = 0;
}; };
self.rowUpdated = function() { self.rowUpdated = function() {
@ -298,8 +299,10 @@ function ANSIEscapeParser(options) {
self.bgColor = arg; self.bgColor = arg;
} else { } else {
self.flags |= arg; self.flags |= arg;
if(0 === arg) { if(0 === arg) {
self.resetColor(); self.resetColor();
//self.flags = 0;
} }
} }
} }

View File

@ -9,7 +9,6 @@ var assert = require('assert');
exports.ButtonView = ButtonView; exports.ButtonView = ButtonView;
function ButtonView(client, options) { function ButtonView(client, options) {
console.log(options);
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true); options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true); options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
options.justify = miscUtil.valueWithDefault(options.justify, 'center'); options.justify = miscUtil.valueWithDefault(options.justify, 'center');
@ -27,4 +26,8 @@ ButtonView.prototype.onKeyPress = function(key, isSpecial) {
if(' ' === key) { if(' ' === key) {
this.emit('action', 'accept'); this.emit('action', 'accept');
} }
}; };
ButtonView.prototype.getViewData = function() {
return null;
};

View File

@ -63,7 +63,6 @@ MenuModule.prototype.enter = function(client) {
}; };
MenuModule.prototype.leave = function() { MenuModule.prototype.leave = function() {
var count = this.viewControllers.length; var count = this.viewControllers.length;
for(var i = 0; i < count; ++i) { for(var i = 0; i < count; ++i) {
this.viewControllers[i].detachClientEvents(); this.viewControllers[i].detachClientEvents();
@ -79,9 +78,7 @@ MenuModule.prototype.beforeArt = function() {
}; };
MenuModule.prototype.mciReady = function(mciMap) { MenuModule.prototype.mciReady = function(mciMap) {
console.log('mciReady')
}; };
MenuModule.prototype.finishedLoading = function() { MenuModule.prototype.finishedLoading = function() {
console.log('finishedLoading')
}; };

View File

@ -70,6 +70,10 @@ TextView.prototype.setFocus = function(focused) {
this.client.term.write(this.getANSIColor(this.getFocusColor())); this.client.term.write(this.getANSIColor(this.getFocusColor()));
}; };
TextView.prototype.getViewData = function() {
return this.text;
};
TextView.prototype.setText = function(text) { TextView.prototype.setText = function(text) {
this.text = text; this.text = text;

View File

@ -49,7 +49,7 @@ function ViewController(client, formId) {
case 'accept' : // :TODO: consider naming this 'done' case 'accept' : // :TODO: consider naming this 'done'
// :TODO: check if id is submit, etc. // :TODO: check if id is submit, etc.
if(self.focusedView && self.focusedView.submit) { if(self.focusedView && self.focusedView.submit) {
self.submitForm(); self.submitForm();
} else { } else {
self.nextFocus(); self.nextFocus();
@ -245,21 +245,26 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) {
if(formConfig) { if(formConfig) {
async.each(Object.keys(formConfig.mci), function onMciConf(mci, eachCb) { async.each(Object.keys(formConfig.mci), function onMciConf(mci, eachCb) {
var viewId = parseInt(mci[2]); // :TODO: what about auto-generated ID's? Do they simply not apply to menu configs? var viewId = parseInt(mci[2]); // :TODO: what about auto-generated ID's? Do they simply not apply to menu configs?
var view = self.getView(viewId);
var mciConf = formConfig.mci[mci]; var mciConf = formConfig.mci[mci];
// :TODO: Break all of this up ... and/or better way of doing it // :TODO: Break all of this up ... and/or better way of doing it
if(mciConf.items) { if(mciConf.items) {
self.getView(viewId).setItems(mciConf.items); view.setItems(mciConf.items);
} }
if(mciConf.submit) { if(mciConf.submit) {
self.getView(viewId).submit = true; // :TODO: should really be actual value view.submit = true; // :TODO: should really be actual value
} }
if(mciConf.focus) { if(mciConf.focus) {
self.switchFocus(viewId); self.switchFocus(viewId);
} }
if(mciConf.text) {
view.setText(mciConf.text);
}
eachCb(null); eachCb(null);
}, },
@ -280,14 +285,21 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) {
self.on('submit', function onSubmit(formData) { self.on('submit', function onSubmit(formData) {
Log.debug( { formData : formData }, 'Submit form'); Log.debug( { formData : formData }, 'Submit form');
var submitCompare = function(value, other) {
console.log(value);
console.log(other);
return false;
};
for(var c = 0; c < formConfig.submit.length; ++c) { for(var c = 0; c < formConfig.submit.length; ++c) {
console.log(formConfig.submit[c]); //console.log(formConfig.submit[c]);
if(ld.isEqual(formData.value, formConfig.submit[c].value)) { if(ld.isEqual(formData.value, formConfig.submit[c].value)) {
self.client.gotoMenuModule(formConfig.submit[c].menu); self.client.gotoMenuModule(formConfig.submit[c].menu);
break; break;
} }
var equal = ld.isEqual(formData.value, formConfig.submit[c].value, submitCompare);
// :TODO: Match various wildcards, etc. // :TODO: Match various wildcards, etc.
} }
}); });

Binary file not shown.

View File

@ -21,7 +21,7 @@
VerticalMenu: { id: 0, submitId: 1, value: { '1': 1 } } VerticalMenu: { id: 0, submitId: 1, value: { '1': 1 } }
Another concept: Another concept:
"menu" : "@helper.js/logoff" -> calls helper.js::logoff(...) "menu" : "@helper.js/logoff" -> calls helper.js::logoff(...)
*/ */
@ -44,7 +44,31 @@
}, },
"login" : { "login" : {
"art" : "login", "art" : "login",
"module" : "login" "module" : "login",
"form" : [
{
"mciReq" : [ "ET1", "ET2", "BN3", "BN4" ],
"mci" :{
"ET1" : {
"focus" : true
},
"BN3" : {
"submit" : true,
"text" : "Login"
},
"BN4" : {
"submit" : true,
"text" : "Cancel"
}
},
"submit" : [
{
"value" : { "3" : null },
"menu" : "pickles"
}
]
}
]
}, },
"logoff" : { "logoff" : {
"art" : "logoff", "art" : "logoff",