* More work on menu system and form handling. Lots of work to do!
This commit is contained in:
parent
d6ffa2b26e
commit
3274908586
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
@ -27,4 +26,8 @@ ButtonView.prototype.onKeyPress = function(key, isSpecial) {
|
|||
if(' ' === key) {
|
||||
this.emit('action', 'accept');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ButtonView.prototype.getViewData = function() {
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -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')
|
||||
};
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ function ViewController(client, formId) {
|
|||
|
||||
case 'accept' : // :TODO: consider naming this 'done'
|
||||
// :TODO: check if id is submit, etc.
|
||||
if(self.focusedView && self.focusedView.submit) {
|
||||
if(self.focusedView && self.focusedView.submit) {
|
||||
self.submitForm();
|
||||
} else {
|
||||
self.nextFocus();
|
||||
|
@ -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.
|
@ -21,7 +21,7 @@
|
|||
VerticalMenu: { id: 0, submitId: 1, value: { '1': 1 } }
|
||||
|
||||
Another concept:
|
||||
|
||||
|
||||
"menu" : "@helper.js/logoff" -> calls helper.js::logoff(...)
|
||||
|
||||
*/
|
||||
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue