This commit is contained in:
@@ -105,8 +105,33 @@ export default {
|
|||||||
//returns the translated message in case the form wants to display it as well
|
//returns the translated message in case the form wants to display it as well
|
||||||
if (err instanceof Error && err.message) {
|
if (err instanceof Error && err.message) {
|
||||||
dealWithError(err.message, vm);
|
dealWithError(err.message, vm);
|
||||||
|
} else if (err.error) {
|
||||||
|
//it's an api error return object, translate and display correctly
|
||||||
|
err = err.error;
|
||||||
|
// {
|
||||||
|
// "code": "2002",
|
||||||
|
// "message": "See server log for details",
|
||||||
|
// "target": "Server internal error"
|
||||||
|
// }
|
||||||
|
let msg = "";
|
||||||
|
if (err.code) {
|
||||||
|
msg += err.code;
|
||||||
|
msg += " - ";
|
||||||
|
msg += vm.$ay.t("ErrorAPI" + err.code);
|
||||||
|
msg += "\n";
|
||||||
|
}
|
||||||
|
if (err.target) {
|
||||||
|
msg += err.target;
|
||||||
|
msg += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err.message) {
|
||||||
|
msg += err.message;
|
||||||
|
msg += "\n";
|
||||||
|
}
|
||||||
|
dealWithError(msg, vm);
|
||||||
} else {
|
} else {
|
||||||
//TODO: this is pretty bad
|
//last resort
|
||||||
let msg = JSON.stringify(err);
|
let msg = JSON.stringify(err);
|
||||||
dealWithError(msg, vm);
|
dealWithError(msg, vm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,16 +457,22 @@ export default {
|
|||||||
let that = this;
|
let that = this;
|
||||||
//determine if this is a new or existing record
|
//determine if this is a new or existing record
|
||||||
let fetchOptions = undefined;
|
let fetchOptions = undefined;
|
||||||
if (data.concurrency) {
|
if (data) {
|
||||||
//has concurrency token, so this is a PUT as it's updating an existing record
|
//data can be blank in a post that triggers an action
|
||||||
fetchOptions = that.fetchPutOptions(data);
|
if (data.concurrency) {
|
||||||
} else {
|
//has concurrency token, so this is a PUT as it's updating an existing record
|
||||||
//Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token
|
fetchOptions = that.fetchPutOptions(data);
|
||||||
fetchOptions = that.fetchPostOptions(data);
|
} else {
|
||||||
//ensure the route doesn't end in /0 which will happen if it's a new record since the edit forms just send the url here with the ID regardless
|
//Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token
|
||||||
if (window.$gz._.endsWith(route, "/0")) {
|
fetchOptions = that.fetchPostOptions(data);
|
||||||
route = route.slice(0, -2);
|
//ensure the route doesn't end in /0 which will happen if it's a new record since the edit forms just send the url here with the ID regardless
|
||||||
|
if (window.$gz._.endsWith(route, "/0")) {
|
||||||
|
route = route.slice(0, -2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//no data, so this is likely just a trigger post
|
||||||
|
fetchOptions = that.fetchPostOptions(data);
|
||||||
}
|
}
|
||||||
let r = await fetch(that.APIUrl(route), fetchOptions);
|
let r = await fetch(that.APIUrl(route), fetchOptions);
|
||||||
that.statusEx(r);
|
that.statusEx(r);
|
||||||
|
|||||||
@@ -285,7 +285,9 @@ export default {
|
|||||||
try {
|
try {
|
||||||
//call fetch key on server
|
//call fetch key on server
|
||||||
let r = await window.$gz.api.upsertEx("license");
|
let r = await window.$gz.api.upsertEx("license");
|
||||||
|
if (r.error) {
|
||||||
|
throw r;
|
||||||
|
}
|
||||||
window.$gz.eventBus.$emit("notify-info", r.data);
|
window.$gz.eventBus.$emit("notify-info", r.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
@@ -317,8 +319,8 @@ function clickHandler(menuItem) {
|
|||||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||||
if (m.owner == FORM_KEY && !m.disabled) {
|
if (m.owner == FORM_KEY && !m.disabled) {
|
||||||
switch (m.key) {
|
switch (m.key) {
|
||||||
case "save":
|
case "fetch":
|
||||||
m.vm.submit();
|
m.vm.fetchKey();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user