diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index b0b6a6d7..c954a525 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -1,4 +1,5 @@ /* Xeslint-disable */ +import _ from "../libs/lodash.min.js"; import store from "../store"; import router from "../router"; import auth from "./auth"; @@ -284,9 +285,15 @@ export default { //determine if this is a new or existing record var fetchOptions = undefined; if (data.concurrencyToken) { + //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 (_.endsWith(route, "/0")) { + route = route.slice(0, -2); + } } fetch(that.APIUrl(route), fetchOptions) .then(that.status) diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index 3892564a..430909c0 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -86,7 +86,7 @@ export default function initialize() { api .get("UserOptions/" + store.state.userId) .then(res => { - if (res.error) { + if (res.error != undefined) { //In a form this would trigger a bunch of validation or error display code but for here and now: //convert error to human readable string for display and popup a notification to user var msg = api.apiErrorToHumanString(res.error); diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index db3801e9..8d710ab7 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -137,7 +137,6 @@ > -