diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index f9580d5b..b360c08c 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -16,6 +16,7 @@ TODO NEXT Test if a deliberate error thrown in the locale text will properly still show the content of the pages that rely on it i.e. inventory, inventorywidgetedit, log DATETIME +- sb able to click on buttons as well as the actual numbers, see if that's possible - 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/src/api/errorhandler.js b/ayanova/src/api/errorhandler.js index b6513514..72377519 100644 --- a/ayanova/src/api/errorhandler.js +++ b/ayanova/src/api/errorhandler.js @@ -36,7 +36,7 @@ export default { // } if (info) { msg += "\ninfo: " + info; - } + } dealWithError(msg); }, handleVueWarning(wmsg, vm, trace) { @@ -48,5 +48,13 @@ export default { msg += "\ntrace: " + trace; } dealWithError(msg); + }, + handleFormError(err) { + //called inside forms when things go wrong but are handled + if (err instanceof Error && err.message) { + dealWithError(err.message); + } else { + dealWithError(err.toString()); + } } }; diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 7cdcecf6..b071073b 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -12,7 +12,8 @@ export default { return store.state.localeText[key]; }, fetch(keys) { - return new Promise(function(resolve, reject) { + return new Promise(function(resolve) { + //, reject //step 1: build an array of keys that we don't have already //Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen var needIt = []; @@ -21,11 +22,14 @@ export default { needIt.push(keys[i]); } } + if (keys[0] == "Log") { + throw new Error("TEST ERROR IN LOCALE"); + } if (needIt.length == 0) { resolve(); - return; } + //step 2: get it fetch(apiUtil.APIUrl("locale/subset"), apiUtil.fetchPostOptions(needIt)) .then(apiUtil.status) @@ -34,11 +38,12 @@ export default { _.forEach(response.data, function(item) { store.commit("addLocaleText", item); }); + resolve(); - }) - .catch(function(error) { - reject(error); }); + // .catch(function(error) { + // reject(error); + // }); }); }, //Keys that all edit forms have in common (saves retyping them over and over) diff --git a/ayanova/src/main.js b/ayanova/src/main.js index 6d6c4f4c..d50bcaad 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -25,6 +25,9 @@ Object.defineProperty(Vue.prototype, "$dayjs", { value: dayjs }); Object.defineProperty(Vue.prototype, "$_", { value: lodash }); Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale }); Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi }); +Object.defineProperty(Vue.prototype, "$gzerror", { + value: errorHandler.handleFormError +}); ///////////////////////////////////////////////////////////////// // FORM VALIDATION diff --git a/ayanova/src/views/log.vue b/ayanova/src/views/log.vue index c0f7618c..d81ebb13 100644 --- a/ayanova/src/views/log.vue +++ b/ayanova/src/views/log.vue @@ -8,7 +8,7 @@