This commit is contained in:
2020-06-13 15:42:57 +00:00
parent fa3a0fc106
commit bb8001bb3e
3 changed files with 46 additions and 13 deletions

View File

@@ -457,16 +457,22 @@ export default {
let that = this;
//determine if this is a new or existing record
let fetchOptions = undefined;
if (data.concurrency) {
//has concurrency token, so this is a PUT as it's updating an existing record
fetchOptions = that.fetchPutOptions(data);
} else {
//Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token
fetchOptions = that.fetchPostOptions(data);
//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);
if (data) {
//data can be blank in a post that triggers an action
if (data.concurrency) {
//has concurrency token, so this is a PUT as it's updating an existing record
fetchOptions = that.fetchPutOptions(data);
} else {
//Does not have a concurrency token so this is a POST as it's posting a new record without a concurrency token
fetchOptions = that.fetchPostOptions(data);
//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);
that.statusEx(r);