From ecd4865fb92d2e94536ad2e980fab738616e5395 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 11 Jun 2019 00:06:18 +0000 Subject: [PATCH] --- ayanova/src/api/gzapi.js | 26 ++++++++++ ayanova/src/views/inventory-widget-edit.vue | 55 ++++++++++++++++++--- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index c954a525..1dc16306 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -224,6 +224,12 @@ export default { return store.state.apiUrl + apiPath; }, ///////////////////////////// + // REPLACE END OF URL + // (used to change ID in url) + replaceAfterLastSlash(theUrl, theReplacement) { + return theUrl.substr(0, theUrl.lastIndexOf("\\") + 1) + theReplacement; + }, + ///////////////////////////// // ENCODE QUERY STRING // buildQuery(obj, sep, eq, name) { @@ -326,6 +332,26 @@ export default { handleError("DELETE", error, route, reject); }); }); + }, + /////////////////////////////////// + // POST DUPLICATE TO API SERVER + // + duplicate(route) { + var that = this; + return new Promise(function duplicateRecordOnServer(resolve, reject) { + fetch(that.APIUrl(route), that.fetchPostOptions(null)) + .then(that.status) + .then(that.json) + .then(response => { + //Note: response.error indicates there is an error, however this is not an unusual condition + //it could be validation errors or other general error so we need to treat it here like it's normal + //and let the caller deal with it appropriately + resolve(response); + }) + .catch(function handleDuplicateError(error) { + handleError("DUPLICATE", error, route, reject); + }); + }); } //new functions above here diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index aec42fc9..246fd761 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -157,7 +157,9 @@