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

View File

@ -9,7 +9,6 @@ var assert = require('assert');
exports.ButtonView = ButtonView;
function ButtonView(client, options) {
console.log(options);
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
options.justify = miscUtil.valueWithDefault(options.justify, 'center');
@ -28,3 +27,7 @@ ButtonView.prototype.onKeyPress = function(key, isSpecial) {
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() {
var count = this.viewControllers.length;
for(var i = 0; i < count; ++i) {
this.viewControllers[i].detachClientEvents();
@ -79,9 +78,7 @@ MenuModule.prototype.beforeArt = function() {
};
MenuModule.prototype.mciReady = function(mciMap) {
console.log('mciReady')
};
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()));
};
TextView.prototype.getViewData = function() {
return this.text;
};
TextView.prototype.setText = function(text) {
this.text = text;

View File

@ -245,21 +245,26 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) {
if(formConfig) {
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 view = self.getView(viewId);
var mciConf = formConfig.mci[mci];
// :TODO: Break all of this up ... and/or better way of doing it
if(mciConf.items) {
self.getView(viewId).setItems(mciConf.items);
view.setItems(mciConf.items);
}
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) {
self.switchFocus(viewId);
}
if(mciConf.text) {
view.setText(mciConf.text);
}
eachCb(null);
},
@ -280,14 +285,21 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) {
self.on('submit', function onSubmit(formData) {
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) {
console.log(formConfig.submit[c]);
//console.log(formConfig.submit[c]);
if(ld.isEqual(formData.value, formConfig.submit[c].value)) {
self.client.gotoMenuModule(formConfig.submit[c].menu);
break;
}
var equal = ld.isEqual(formData.value, formConfig.submit[c].value, submitCompare);
// :TODO: Match various wildcards, etc.
}
});

Binary file not shown.

View File

@ -44,7 +44,31 @@
},
"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" : {
"art" : "logoff",