From afb7854ea50f4bdf00d337d6045a094db0cf4281 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 8 Jun 2019 11:57:36 -0600 Subject: [PATCH] Clean up logging a bit & implement 'omit' * 'omit' can be set to omit views from form submission * Don't log as much noise --- core/view.js | 6 ++++++ core/view_controller.js | 23 +++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/view.js b/core/view.js index 7d3c5693..58a305e4 100644 --- a/core/view.js +++ b/core/view.js @@ -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; diff --git a/core/view_controller.js b/core/view_controller.js index 84f33756..9c0ffe19 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -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;