This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user