Many updates to view validation framework

This commit is contained in:
Bryan Ashby 2015-12-10 21:45:02 -07:00
parent 490d71c180
commit cb3ae84bc5
1 changed files with 27 additions and 8 deletions

View File

@ -72,6 +72,7 @@ function ViewController(options) {
case 'accept' : case 'accept' :
if(self.focusedView && self.focusedView.submit) { if(self.focusedView && self.focusedView.submit) {
// :TODO: need to do validation here!!!
self.submitForm(key); self.submitForm(key);
} else { } else {
self.nextFocus(); self.nextFocus();
@ -161,6 +162,10 @@ function ViewController(options) {
// :TODO: handle propAsset.location for @method script specification // :TODO: handle propAsset.location for @method script specification
if('systemMethod' === propAsset.type) { if('systemMethod' === propAsset.type) {
// :TODO: implementation validation @systemMethod handling! // :TODO: implementation validation @systemMethod handling!
var methodModule = require(paths.join(__dirname, 'system_view_validate.js'));
if(_.isFunction(methodModule[propAsset.asset])) {
propValue = methodModule[propAsset.asset];
}
} else { } else {
if(_.isFunction(self.client.currentMenuModule.menuMethods[propAsset.asset])) { if(_.isFunction(self.client.currentMenuModule.menuMethods[propAsset.asset])) {
propValue = self.client.currentMenuModule.menuMethods[propAsset.asset]; propValue = self.client.currentMenuModule.menuMethods[propAsset.asset];
@ -391,14 +396,28 @@ ViewController.prototype.switchFocus = function(id) {
if(focusedView && focusedView.validate) { if(focusedView && focusedView.validate) {
focusedView.validate(focusedView.getData(), function validated(isValid, msgProp) { focusedView.validate(focusedView.getData(), function validated(err) {
if(isValid) { if(_.isFunction(self.client.currentMenuModule.menuMethods.viewValidationListener)) {
performSwitch(); if(err) {
} else { err.view = focusedView;
if(_.isFunction(self.client.currentMenuModule.menuMethods.validationFailure)) { }
self.client.currentMenuModule.menuMethods.validationFailure(focusedView, msgProp, function validateFailNext() {
self.client.currentMenuModule.menuMethods.viewValidationListener(err, function validateComplete(newFocusId) {
if(err) {
// :TODO: switchFocus() really needs a cb --
var newFocusView;
if(newFocusId) {
newFocusView = self.getView(newFocusId) || focusedView;
}
self.setViewFocusWithEvents(newFocusView, true);
} else {
performSwitch();
}
}); });
} else {
if(!err) {
performSwitch();
} }
} }
}); });