Clean up logging a bit & implement 'omit'

* 'omit' can be set to omit views from form submission
* Don't log as much noise
This commit is contained in:
Bryan Ashby 2019-06-08 11:57:36 -06:00
parent 094385a150
commit afb7854ea5
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
2 changed files with 15 additions and 14 deletions

View File

@ -220,6 +220,12 @@ View.prototype.setPropertyValue = function(propName, value) {
case 'argName' : this.submitArgName = value; break;
case 'omit' :
if(_.isBoolean(value)) {
this.omitFromSubmission = value; break;
}
break;
case 'validate' :
if(_.isFunction(value)) {
this.validate = value;

View File

@ -46,6 +46,8 @@ function ViewController(options) {
return; // ignore until this is finished!
}
self.client.log.trace( { actionBlock }, 'Action match' );
self.waitActionCompletion = true;
menuUtil.handleAction(self.client, formData, actionBlock, (err) => {
if(err) {
@ -121,9 +123,7 @@ function ViewController(options) {
self.emit('submit', this.getFormData(key));
};
// :TODO: replace this in favor of overriding toJSON() for various things such that logging will *never* output them
this.getLogFriendlyFormData = function(formData) {
// :TODO: these fields should be part of menu.json sensitiveMembers[]
var safeFormData = _.cloneDeep(formData);
if(safeFormData.value.password) {
safeFormData.value.password = '*****';
@ -330,15 +330,6 @@ function ViewController(options) {
}
}
}
self.client.log.trace(
{
formValue : formValue,
actionValue : actionValue
},
'Action match'
);
return true;
};
@ -577,7 +568,7 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
if(false === self.noInput) {
self.on('submit', function promptSubmit(formData) {
self.client.log.trace( { formData : self.getLogFriendlyFormData(formData) }, 'Prompt submit');
self.client.log.trace( { formData }, 'Prompt submit');
const doSubmitNotify = () => {
if(options.submitNotify) {
@ -752,8 +743,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
}
self.on('submit', function formSubmit(formData) {
self.client.log.trace( { formData : self.getLogFriendlyFormData(formData) }, 'Form submit');
self.client.log.trace( { formData }, 'Form submit');
//
// Locate configuration for this form ID
@ -870,6 +860,11 @@ ViewController.prototype.getFormData = function(key) {
return;
}
// some form values may be omitted from submission all together
if(view.omitFromSubmission) {
return;
}
viewData = view.getData();
if(_.isUndefined(viewData)) {
return;