This commit is contained in:
@@ -423,7 +423,7 @@ export default {
|
||||
///////////////////////////////////
|
||||
// GET DATA FROM API SERVER
|
||||
//
|
||||
async getEx(route) {
|
||||
async get(route) {
|
||||
try {
|
||||
let that = this;
|
||||
let r = await fetch(that.APIUrl(route), that.fetchGetOptions());
|
||||
@@ -435,25 +435,7 @@ export default {
|
||||
handleError("GET", error, route, reject);
|
||||
}
|
||||
},
|
||||
///////////////////////////////////
|
||||
// GET DATA FROM API SERVER
|
||||
//
|
||||
get(route) {
|
||||
let that = this;
|
||||
return new Promise(function getDataFromServer(resolve, reject) {
|
||||
fetch(that.APIUrl(route), that.fetchGetOptions())
|
||||
.then(that.status)
|
||||
.then(that.extractBody)
|
||||
// eslint-disable-next-line
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch(function handleGetError(error) {
|
||||
//fundamental error, can't proceed with this call
|
||||
handleError("GET", error, route, reject);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
//////////////////////////////////////
|
||||
// Test delay for troubleshooting
|
||||
//
|
||||
@@ -504,7 +486,7 @@ export default {
|
||||
///////////////////////////////////
|
||||
// DELETE DATA FROM API SERVER
|
||||
//
|
||||
async removeEx(route) {
|
||||
async remove(route) {
|
||||
let that = this;
|
||||
try {
|
||||
let r = await fetch(that.APIUrl(route), that.fetchRemoveOptions());
|
||||
@@ -517,67 +499,27 @@ export default {
|
||||
handleError("DELETE", error, route);
|
||||
}
|
||||
},
|
||||
///////////////////////////////////
|
||||
// DELETE DATA FROM API SERVER
|
||||
//
|
||||
remove(route) {
|
||||
let that = this;
|
||||
return new Promise(function removeDataFromServer(resolve, reject) {
|
||||
fetch(that.APIUrl(route), that.fetchRemoveOptions())
|
||||
.then(that.status)
|
||||
//.then(that.extractBody)
|
||||
// eslint-disable-next-line
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch(function handleRemoveError(error) {
|
||||
//fundamental error, can't proceed with this call
|
||||
handleError("DELETE", error, route, reject);
|
||||
});
|
||||
});
|
||||
},
|
||||
///////////////////////////////////
|
||||
// POST DUPLICATE TO API SERVER
|
||||
//
|
||||
duplicate(route) {
|
||||
let that = this;
|
||||
return new Promise(function duplicateRecordOnServer(resolve, reject) {
|
||||
fetch(that.APIUrl(route), that.fetchPostOptions(null))
|
||||
.then(that.status)
|
||||
.then(that.extractBody)
|
||||
// eslint-disable-next-line
|
||||
.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);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
///////////////////////////////////
|
||||
// POST FILE ATTACHMENTS
|
||||
// @param {ayaId:objectid, ayaType:objectType, files:[array of files]}
|
||||
//
|
||||
uploadAttachment(at) {
|
||||
async uploadAttachment(at) {
|
||||
let that = this;
|
||||
try {
|
||||
var files = at.files;
|
||||
var data = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
data.append(files[i].name, files[i]);
|
||||
}
|
||||
|
||||
var files = at.files;
|
||||
var data = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
data.append(files[i].name, files[i]);
|
||||
}
|
||||
data.append("AttachToObjectType", at.ayaType);
|
||||
data.append("AttachToObjectId", at.ayaId);
|
||||
data.append("Notes", at.notes);
|
||||
data.append("FileData", at.fileData);
|
||||
|
||||
data.append("AttachToObjectType", at.ayaType);
|
||||
data.append("AttachToObjectId", at.ayaId);
|
||||
data.append("Notes", at.notes);
|
||||
data.append("FileData", at.fileData);
|
||||
//-----------------
|
||||
|
||||
//-----------------
|
||||
|
||||
return new Promise(function postAttachmentToServer(resolve, reject) {
|
||||
let fetchOptions = {
|
||||
method: "post",
|
||||
mode: "cors",
|
||||
@@ -587,19 +529,15 @@ export default {
|
||||
body: data
|
||||
};
|
||||
|
||||
fetch(that.APIUrl("attachment"), fetchOptions)
|
||||
.then(that.status)
|
||||
.then(that.extractBody)
|
||||
// eslint-disable-next-line
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch(function handlePostAttachment(error) {
|
||||
handleError("POSTATTACHMENT", error, route, reject);
|
||||
});
|
||||
});
|
||||
//---------------
|
||||
let r = await fetch(that.APIUrl("attachment"), fetchOptions);
|
||||
that.statusEx(r);
|
||||
r = await that.extractBodyEx(r);
|
||||
return r;
|
||||
} catch (error) {
|
||||
handleError("POSTATTACHMENT", error, route, reject);
|
||||
}
|
||||
}
|
||||
//---------------
|
||||
|
||||
//new functions above here
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user