From 5224a03500441970fb5e801fd6d409e6c84f525a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 8 Mar 2019 21:21:15 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 19 ++++++---- ayanova/package-lock.json | 5 --- ayanova/package.json | 1 - ayanova/src/api/gzaftervalidator.js | 11 ++++-- ayanova/src/views/inventory-widget-edit.vue | 41 +++++++++++++++++---- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 0ce61fec..8f29d38e 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -17,13 +17,18 @@ TODO NEXT DATETIME -- Does it validate properly? NO. Get validation working!! - - So it looks like it will need a custom validator as it completely barfs on my string date format coming from the server - - https://baianat.github.io/vee-validate/guide/custom-rules.html#creating-a-custom-rule - - https://baianat.github.io/vee-validate/concepts/components.html#how-it-works - - possibly helpful https://stackoverflow.com/questions/47982820/vuejs-vee-validate-in-custom-components - - or https://duckduckgo.com/?q=vee+validate+with+custom+component&t=ffab&atb=v134-6__&ia=web - +- Validation + - after much fuckery it's becoming clear that between the localization requirements and the complexity of server broken rules coming back from the api that I should just use my own validation code + - See here: https://vuetifyjs.com/en/components/forms#form + - What is needed is a class that returns an array of functions that can be passed to vuetify "rules" property of components + On change each rule is called in turn and if one returns false or a string then it's in an error state + - I also need to add that it scans and or keeps a collection of broken rules that come back from the server and each component checks a rule that checks in turn for server broken rules in last api call + - And my rules object needs to be localized so I guess it should be aware of the locale object and work with it as required + - Should it lazy load error translations? (In as batchy a way as possible?) + - Or, perhaps it's more convenient to cache all possible regular form entry errors since there isn't really that many, perhaps less than a dozen when it comes down to it + - My rules object needs to be coded so I can easily specify a collection of rules appropriate to a form field + - So, for example let's say I have a date input, if I commonly need one to be required and be after or before another field then I should have a single combined rule of + RequiredAndAfterTarget and this method is aggregates both the required and the After rules into a single collection returned - Test on mobile and desktop all browsers before moving on, it must be solid with error handling (required, after before etc) and etc and then if all is well we can move on to the other field types diff --git a/ayanova/package-lock.json b/ayanova/package-lock.json index 4d0f0bd0..a191da08 100644 --- a/ayanova/package-lock.json +++ b/ayanova/package-lock.json @@ -15930,11 +15930,6 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, - "vee-validate": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/vee-validate/-/vee-validate-2.1.7.tgz", - "integrity": "sha512-IyPDTTvIRY6o9y14jXlgfY76Qv+hmvYDwNaMn9JY5KbQN8a1tJAu7H/+a/+EdHg1w8Zl9tsdG8lndGqY1lyMzQ==" - }, "vendors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.2.tgz", diff --git a/ayanova/package.json b/ayanova/package.json index bdadf8df..b3f9dabc 100644 --- a/ayanova/package.json +++ b/ayanova/package.json @@ -16,7 +16,6 @@ "nprogress": "^0.2.0", "register-service-worker": "^1.6.2", "typeface-roboto": "0.0.54", - "vee-validate": "^2.1.7", "vue": "^2.6.8", "vue-router": "^3.0.2", "vuetify": "^1.5.5", diff --git a/ayanova/src/api/gzaftervalidator.js b/ayanova/src/api/gzaftervalidator.js index 0952f90b..a1fe38d8 100644 --- a/ayanova/src/api/gzaftervalidator.js +++ b/ayanova/src/api/gzaftervalidator.js @@ -1,8 +1,13 @@ // import { isAfter, isEqual } from "date-fns"; // import { parseDate as parse } from "../utils/date"; import dayjs from "dayjs"; - +/*eslint-disable */ const gzAfterValidator = (value, { targetValue } = {}) => { + if (!targetValue) { + console.log("GZAFTERVALIDATOR - TARGET IS EMPTY!"); + return false; + //throw "GZAFTERVALIDATOR - TARGET IS EMPTY"; + } value = dayjs(value); targetValue = dayjs(targetValue); @@ -10,8 +15,8 @@ const gzAfterValidator = (value, { targetValue } = {}) => { if (!value || !targetValue) { return false; } - /*eslint-disable */ - debugger; + + //debugger; return value.isAfter(targetValue); }; diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index d3844edc..317fbdb3 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -49,14 +49,13 @@ > - + + + - + + + + +