From 67d46052c776992ff63531752b4c71fc0fbcc8a1 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 4 Apr 2019 17:20:42 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 19 ++--------- ayanova/src/api/apiutil.js | 20 ++++++++++-- ayanova/src/views/inventory-widget-edit.vue | 35 ++++----------------- 3 files changed, 26 insertions(+), 48 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index fde7aec8..399b3179 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -30,25 +30,10 @@ FIX: - Server form validation errors displayed correctly - DONE control ones under control where local form validation errors show - DONE whole object ones at top - - Server form validation errors cleared in individual inputs upon any change to them (but form overall ones stay until submitted) - - ###### HERE!!!!!!!! - - Current issue: Found a way to trigger clearing but - - does it cause excessive re-validation?? - - Remove server errors entirely if they were only related to the fields that are now removed from the details collection - - NOT NEEDED? - Possible solutions to old problem of not removing old server validation msgs: - - LAST DITCH BEFORE ABANDONING THIS SYSTEM: Try making the whole form validate in the component and separately in gzvalidate - - Move all server errors to the server error box and don't put them into the fields local validation errors (keep the two separate and try to avoid as many server errors as possible) - - This might make sense since in reality we should almost never see a server error for a field unless a complex business rule is being broken or something, low level validation should handle it at the form level - - Also, all this code is starting to get too complex and ugly and I'm worried about future proofing so a simpler method might be far better - - Maybe like this: on submit clear local errors, put all server errors that come back into the form data locally so it gets picked up by the errorbox and don't involve gzvalidate at all!! - - This way we don't need to use gzvalidate for anything but local shit - - Also it separates the server error stuff from the validation stuff very neatly so there is no need for a lot of fragile fateful futurefrail fuckery - - - + - DONE Server form validation errors cleared in individual inputs upon any change to them and general if it only applies to validation - On submit: - Doesn't happen if any local validation errors - - All server errors clear on submit + - DONE: All server errors clear on submit - Validation short circuits if form is loading and no data yet - Validation short circuits if no server errors at all diff --git a/ayanova/src/api/apiutil.js b/ayanova/src/api/apiutil.js index 899e4aa2..06cd878e 100644 --- a/ayanova/src/api/apiutil.js +++ b/ayanova/src/api/apiutil.js @@ -2,6 +2,7 @@ import store from "../store"; import router from "../router"; import auth from "./auth"; +import errorHandler from "./errorhandler"; var stringifyPrimitive = function(v) { switch (typeof v) { @@ -19,6 +20,19 @@ var stringifyPrimitive = function(v) { } }; +var devShowUnknownError = function(error) { + if (errorHandler.devMode) { + // eslint-disable-next-line + console.log("apiutil::devShowUnknownError, error is:"); + // eslint-disable-next-line + console.log(error); + // eslint-disable-next-line + alert( + "DEV ERROR apiutil::devShowUnknownError - unexpected error during api operation see console " + ); + } +}; + export default { status(response) { if (response.status == 401) { @@ -204,7 +218,8 @@ export default { auth.logout(); router.push("/login"); } else { - alert("Error: " + errorMessage); + //This should never get called because any issue should be addressed above in a proper error handler + devShowUnknownError(error); reject(error); } }); @@ -247,7 +262,8 @@ export default { auth.logout(); router.push("/login"); } else { - //alert("Error: " + errorMessage); + //This should never get called because any issue should be addressed above in a proper error handler + devShowUnknownError(error); reject(error); } }); diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index cc94f18c..fd21d02c 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -174,19 +174,12 @@ export default { return { obj: {}, serverError: {}, - formReady: false, - someerror: - "blah blahv
blah blah" + "\n test line 3" + "\r\n Test line 4" + formReady: false }; }, methods: { - Change(ref) { - //debugger; - //console.log("CHANGE - " + ref); - this.$gzv.Change(this, ref); - //Make form re-validate here and if it works then make it do it only if gzv.change returns true or something indicating it's required to re-validate or clear that input's errors - // this.$refs.form.resetValidation(); - // this.$refs.form.validate(); + Change(ref) { + this.$gzv.Change(this, ref); }, getDataFromApi() { var url = "Widget/" + this.$route.params.id; @@ -224,27 +217,11 @@ export default { that.obj.concurrencyToken = res.data.concurrencyToken; } } - }) - .catch(function(error) { - //we should be here if it was a gross error of some kind not a mild one like validation but more like if the server doesn't exist or something I guess - - console.log(error); - alert("Houston, we have a problem"); }); + //In theory all exceptions should be handled by the gzapi methods, so we should not need to deal with this in the form very often if at all + // .catch(function(error) { + // }); - //example from login form - // if (this.input.username != "" && this.input.password != "") { - // auth - // .authenticate(this.input.username, this.input.password) - // .then(() => { - // this.$router.replace({ name: "home" }); - // }) - // .catch(function(error) { - // /* xeslint-disable-next-line */ - // //console.log(error); - // alert("login failed: " + error); - // }); - // } } //end of submit() } };