This commit is contained in:
@@ -35,6 +35,7 @@ var devShowUnknownError = function(error) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
status(response) {
|
status(response) {
|
||||||
|
//Handle expected api errors
|
||||||
if (response.status == 401) {
|
if (response.status == 401) {
|
||||||
//must reject if not authorized
|
//must reject if not authorized
|
||||||
return Promise.reject(new Error("401 - NOT AUTHORIZED"));
|
return Promise.reject(new Error("401 - NOT AUTHORIZED"));
|
||||||
@@ -43,6 +44,7 @@ export default {
|
|||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
} else {
|
} else {
|
||||||
|
//log unhandled api error
|
||||||
store.commit(
|
store.commit(
|
||||||
"logItem",
|
"logItem",
|
||||||
"API error: status=" +
|
"API error: status=" +
|
||||||
@@ -52,10 +54,7 @@ export default {
|
|||||||
", url=" +
|
", url=" +
|
||||||
response.url
|
response.url
|
||||||
);
|
);
|
||||||
|
//let it float up for dealing with by caller(s)
|
||||||
//TODO: If no viable data to return then should reject, otherwise should resolve regardless
|
|
||||||
//Nope because we will never get here if nothing at all was returned so what is this actually doing??
|
|
||||||
|
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
21
ayanova/src/api/gzutil.js
Normal file
21
ayanova/src/api/gzutil.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/* Xeslint-disable */
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// General utility library
|
||||||
|
//
|
||||||
|
export default {
|
||||||
|
///////////////////////////////
|
||||||
|
// CLEAN OBJECT
|
||||||
|
// Clear all properties from object without resorting to assigning a new object (o={})
|
||||||
|
// which can be problematic in some cases (IE bugs, watched data items in forms etc)
|
||||||
|
|
||||||
|
RemoveAllPropertiesFromObject(o) {
|
||||||
|
for (var variableKey in o) {
|
||||||
|
if (o.hasOwnProperty(variableKey)) {
|
||||||
|
delete o[variableKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//new functions above here
|
||||||
|
};
|
||||||
@@ -485,7 +485,7 @@ Here are all the API level error codes that can be returned by the API server:
|
|||||||
//If there are no more errors in details then remove the whole thing as it's no longer required
|
//If there are no more errors in details then remove the whole thing as it's no longer required
|
||||||
if (v.serverError.details && v.serverError.details.length < 1) {
|
if (v.serverError.details && v.serverError.details.length < 1) {
|
||||||
if (v.serverError.code == "2200") {
|
if (v.serverError.code == "2200") {
|
||||||
this.RemoveAllProperties(v.serverError);
|
v.$gzutil.RemoveAllPropertiesFromObject(v.serverError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,18 +10,22 @@ import "./registerServiceWorker";
|
|||||||
import errorHandler from "./api/errorhandler";
|
import errorHandler from "./api/errorhandler";
|
||||||
import NProgress from "nprogress";
|
import NProgress from "nprogress";
|
||||||
import "nprogress/nprogress.css";
|
import "nprogress/nprogress.css";
|
||||||
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import lodash from "./libs/lodash.min.js";
|
import lodash from "./libs/lodash.min.js";
|
||||||
|
//my libs
|
||||||
|
import gzutil from "./api/gzutil";
|
||||||
import locale from "./api/locale";
|
import locale from "./api/locale";
|
||||||
import gzapi from "./api/apiutil";
|
import gzapi from "./api/apiutil";
|
||||||
import gzvalidate from "./api/gzvalidate";
|
import gzvalidate from "./api/gzvalidate";
|
||||||
import "@/assets/css/main.css";
|
import "@/assets/css/main.css";
|
||||||
|
|
||||||
|
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// LIBS AND GLOBAL ITEMS
|
// LIBS AND GLOBAL ITEMS
|
||||||
// (https://medium.com/js-dojo/use-any-javascript-library-with-vue-js-3f7e2a4974a8)
|
// (https://medium.com/js-dojo/use-any-javascript-library-with-vue-js-3f7e2a4974a8)
|
||||||
//
|
//
|
||||||
|
Object.defineProperty(Vue.prototype, "$gzutil", { value: gzutil });
|
||||||
Object.defineProperty(Vue.prototype, "$dayjs", { value: dayjs });
|
Object.defineProperty(Vue.prototype, "$dayjs", { value: dayjs });
|
||||||
Object.defineProperty(Vue.prototype, "$_", { value: lodash });
|
Object.defineProperty(Vue.prototype, "$_", { value: lodash });
|
||||||
Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
|
Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
|
||||||
|
|||||||
@@ -196,17 +196,13 @@ export default {
|
|||||||
var url = "Widget/" + this.$route.params.id;
|
var url = "Widget/" + this.$route.params.id;
|
||||||
|
|
||||||
//clear any errors that might be around from previous submit
|
//clear any errors that might be around from previous submit
|
||||||
this.$gzv.RemoveAllProperties(this.serverError);
|
this.$gzutil.RemoveAllPropertiesFromObject(this.serverError);
|
||||||
|
|
||||||
this.$gzapi
|
this.$gzapi
|
||||||
.upsert(url, this.obj)
|
.upsert(url, this.obj)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
//debugger;
|
|
||||||
//Set errors so form can pick them up for controls in canHasServerErrors
|
|
||||||
that.serverError = res.error;
|
that.serverError = res.error;
|
||||||
// that.$refs.form.resetValidation();
|
|
||||||
// that.$refs.form.validate();
|
|
||||||
} else {
|
} else {
|
||||||
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
|
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
|
||||||
if (res.id) {
|
if (res.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user