* Fix bug where 'submit' property was ignored in favor of highest MCI ID always; Will now properly set view with 'submit' to true else rely on highest ID

This commit is contained in:
Bryan Ashby 2018-01-15 20:30:55 -07:00
parent a8d5e84779
commit d1593ed159

View file

@ -228,25 +228,25 @@ function ViewController(options) {
}; };
this.applyViewConfig = function(config, cb) { this.applyViewConfig = function(config, cb) {
var highestId = 1; let highestId = 1;
var submitId; let submitId;
var initialFocusId = 1; let initialFocusId = 1;
async.each(Object.keys(config.mci || {}), function entry(mci, nextItem) { async.each(Object.keys(config.mci || {}), function entry(mci, nextItem) {
var mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs???? const mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs????
if(null === mciMatch) { if(null === mciMatch) {
self.client.log.warn( { mci : mci }, 'Unable to parse MCI code'); self.client.log.warn( { mci : mci }, 'Unable to parse MCI code');
return; return;
} }
var viewId = parseInt(mciMatch[2]); const viewId = parseInt(mciMatch[2]);
assert(!isNaN(viewId), 'Cannot parse view ID: ' + mciMatch[2]); // shouldn't be possible with RegExp used assert(!isNaN(viewId), 'Cannot parse view ID: ' + mciMatch[2]); // shouldn't be possible with RegExp used
if(viewId > highestId) { if(viewId > highestId) {
highestId = viewId; highestId = viewId;
} }
var view = self.getView(viewId); const view = self.getView(viewId);
if(!view) { if(!view) {
self.client.log.warn( { viewId : viewId }, 'Cannot find view'); self.client.log.warn( { viewId : viewId }, 'Cannot find view');
@ -254,7 +254,7 @@ function ViewController(options) {
return; return;
} }
var mciConf = config.mci[mci]; const mciConf = config.mci[mci];
self.setViewPropertiesFromMCIConf(view, mciConf); self.setViewPropertiesFromMCIConf(view, mciConf);
@ -262,9 +262,13 @@ function ViewController(options) {
initialFocusId = viewId; initialFocusId = viewId;
} }
if(true === view.submit) {
submitId = viewId;
}
nextItem(null); nextItem(null);
}, },
function complete(err) { err => {
// default to highest ID if no 'submit' entry present // default to highest ID if no 'submit' entry present
if(!submitId) { if(!submitId) {
var highestIdView = self.getView(highestId); var highestIdView = self.getView(highestId);
@ -275,7 +279,7 @@ function ViewController(options) {
} }
} }
cb(err, { initialFocusId : initialFocusId } ); return cb(err, { initialFocusId : initialFocusId } );
}); });
}; };