Re-apply some Prettier formatting after merge

This commit is contained in:
Bryan Ashby
2022-06-12 14:12:03 -06:00
parent c93b8cda81
commit 9172fdda9d
37 changed files with 978 additions and 712 deletions

View File

@@ -257,56 +257,59 @@ function ViewController(options) {
}
};
this.applyViewConfig = function(config, cb) {
this.applyViewConfig = function (config, cb) {
let highestId = 1;
let submitId;
let initialFocusId = 1;
async.each(Object.keys(config.mci || {}), function entry(mci, nextItem) {
const mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs????
if(null === mciMatch) {
self.client.log.warn( { mci : mci }, 'Unable to parse MCI code');
return;
}
const viewId = parseInt(mciMatch[2]);
assert(!isNaN(viewId), 'Cannot parse view ID: ' + mciMatch[2]); // shouldn't be possible with RegExp used
if(viewId > highestId) {
highestId = viewId;
}
const view = self.getView(viewId);
if(!view) {
return nextItem(null);
}
const mciConf = config.mci[mci];
self.setViewPropertiesFromMCIConf(view, mciConf);
if(mciConf.focus) {
initialFocusId = viewId;
}
if(true === view.submit) {
submitId = viewId;
}
nextItem(null);
},
err => {
// default to highest ID if no 'submit' entry present
if(!submitId) {
const highestIdView = self.getView(highestId);
if(highestIdView) {
highestIdView.submit = true;
async.each(
Object.keys(config.mci || {}),
function entry(mci, nextItem) {
const mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs????
if (null === mciMatch) {
self.client.log.warn({ mci: mci }, 'Unable to parse MCI code');
return;
}
}
return cb(err, { initialFocusId : initialFocusId } );
});
const viewId = parseInt(mciMatch[2]);
assert(!isNaN(viewId), 'Cannot parse view ID: ' + mciMatch[2]); // shouldn't be possible with RegExp used
if (viewId > highestId) {
highestId = viewId;
}
const view = self.getView(viewId);
if (!view) {
return nextItem(null);
}
const mciConf = config.mci[mci];
self.setViewPropertiesFromMCIConf(view, mciConf);
if (mciConf.focus) {
initialFocusId = viewId;
}
if (true === view.submit) {
submitId = viewId;
}
nextItem(null);
},
err => {
// default to highest ID if no 'submit' entry present
if (!submitId) {
const highestIdView = self.getView(highestId);
if (highestIdView) {
highestIdView.submit = true;
}
}
return cb(err, { initialFocusId: initialFocusId });
}
);
};
// method for comparing submitted form data to configuration entries