This commit is contained in:
@@ -34,7 +34,6 @@ export default {
|
||||
if (!window.$gz._.isArray(enumKey)) {
|
||||
enumKey = [enumKey];
|
||||
}
|
||||
|
||||
for (let i = 0; i < enumKey.length; i++) {
|
||||
//check if list
|
||||
//if not then fetch it and store it
|
||||
@@ -43,27 +42,25 @@ export default {
|
||||
if (!window.$gz._.has(window.$gz.store.state.enums, k)) {
|
||||
let that = this;
|
||||
// eslint-disable-next-line
|
||||
await that.fetchEnumKey(k).then((dat) => {
|
||||
//massage the data as necessary
|
||||
let e = { enumKey: k, items: {} };
|
||||
for (let i = 0; i < dat.length; i++) {
|
||||
let o = dat[i];
|
||||
e.items[o.id] = o.name;
|
||||
}
|
||||
//stuff the data into the store
|
||||
window.$gz.store.commit("setEnum", e);
|
||||
});
|
||||
let dat = await that.fetchEnumKey(k);
|
||||
//massage the data as necessary
|
||||
let e = { enumKey: k, items: {} };
|
||||
for (let i = 0; i < dat.length; i++) {
|
||||
let o = dat[i];
|
||||
e.items[o.id] = o.name;
|
||||
}
|
||||
//stuff the data into the store
|
||||
window.$gz.store.commit("setEnum", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
fetchEnumKey(enumKey) {
|
||||
async fetchEnumKey(enumKey) {
|
||||
// eslint-disable-next-line
|
||||
return window.$gz.api.get("enum-list/list/" + enumKey).then((res) => {
|
||||
//We never expect there to be no data here
|
||||
if (!res.data) {
|
||||
throw res;
|
||||
}
|
||||
return res.data;
|
||||
});
|
||||
let res = await window.$gz.api.get("enum-list/list/" + enumKey);
|
||||
//We never expect there to be no data here
|
||||
if (!res.data) {
|
||||
throw res;
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,30 +17,19 @@ function addDataKeyNames(obj) {
|
||||
|
||||
export default {
|
||||
// cache the form customization data if it's not already present
|
||||
//cache invalidation is hard, this needs it...hmmm....
|
||||
//for now will rely on logout and back in to clear up any customization issues
|
||||
get(formKey) {
|
||||
return new Promise(function getFormTemplate(resolve) {
|
||||
if (
|
||||
!window.$gz._.has(window.$gz.store.state.formCustomTemplate, formKey)
|
||||
) {
|
||||
//fetch and populate the store
|
||||
window.$gz.api.get("form-custom/" + formKey).then(res => {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
}
|
||||
window.$gz.store.commit("setFormCustomTemplateItem", {
|
||||
formKey: formKey,
|
||||
concurrency: res.data.concurrency,
|
||||
value: addDataKeyNames(JSON.parse(res.data.template))
|
||||
});
|
||||
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
async get(formKey) {
|
||||
if (!window.$gz._.has(window.$gz.store.state.formCustomTemplate, formKey)) {
|
||||
//fetch and populate the store
|
||||
let res = await window.$gz.api.get("form-custom/" + formKey);
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
}
|
||||
});
|
||||
window.$gz.store.commit("setFormCustomTemplateItem", {
|
||||
formKey: formKey,
|
||||
concurrency: res.data.concurrency,
|
||||
value: addDataKeyNames(JSON.parse(res.data.template))
|
||||
});
|
||||
}
|
||||
},
|
||||
set(formKey, token, template) {
|
||||
window.$gz.store.commit("setFormCustomTemplateItem", {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -216,7 +216,7 @@ export default {
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
async created() {
|
||||
let vm = this;
|
||||
//------------------
|
||||
//Test ui feedback mechanisms here:
|
||||
@@ -242,16 +242,14 @@ export default {
|
||||
icon: "",
|
||||
title: ""
|
||||
});
|
||||
window.$gz.api
|
||||
.get("notify/hello")
|
||||
.then(res => {
|
||||
if (res.data != null) {
|
||||
vm.showEvalUsers = res.data;
|
||||
}
|
||||
})
|
||||
.catch(function handleGetTrialModeError(error) {
|
||||
//squash it, this isn't critical
|
||||
});
|
||||
try {
|
||||
let res = await window.$gz.api.get("notify/hello");
|
||||
if (res.data != null) {
|
||||
vm.showEvalUsers = res.data;
|
||||
}
|
||||
} catch (error) {
|
||||
//squash it, this isn't critical
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -274,9 +272,6 @@ export default {
|
||||
let vm = this;
|
||||
if (vm.input.username != "" && vm.input.password != "") {
|
||||
vm.errorBadCreds = false;
|
||||
|
||||
//auth directly bypass auth here
|
||||
//==========================
|
||||
let loggedInWithKnownPassword =
|
||||
vm.input.username == "superuser" && vm.input.password == "l3tm3in";
|
||||
|
||||
@@ -347,75 +342,6 @@ export default {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//==========================
|
||||
|
||||
//############## OLD AUTH ########################
|
||||
// auth
|
||||
// .authenticate(vm.input.username, vm.input.password)
|
||||
// .then(() => {
|
||||
// /*public enum LicenseStatus
|
||||
// {
|
||||
// NONE = 0,//fast track
|
||||
// ActiveTrial = 1,//slow track
|
||||
// ExpiredTrial = 2,//fast track
|
||||
// ActivePurchased = 3,//slow track
|
||||
// ExpiredPurchased = 4,//fast track
|
||||
// Revoked = 5//slow track
|
||||
// } */
|
||||
// //check if support and updates has expired and is paid for license and show warning if so
|
||||
// if (
|
||||
// vm.$store.state.globalSettings.maintenanceExpired &&
|
||||
// (vm.$store.state.globalSettings.licenseStatus == 3 ||
|
||||
// vm.$store.state.globalSettings.licenseStatus == 4)
|
||||
// ) {
|
||||
// (async function() {
|
||||
// await window.$gz.dialog.displayLTModalNotificationMessage(
|
||||
// "MaintenanceExpiredNote",
|
||||
// "MaintenanceExpired",
|
||||
// "error",
|
||||
// "https://www.ayanova.com/subscriptionexpired.htm"
|
||||
// );
|
||||
// })();
|
||||
// }
|
||||
// if (vm.$store.state.openObject != null) {
|
||||
// window.$gz.eventBus.$emit("openobject", null);
|
||||
// } else {
|
||||
// vm.$router.push(vm.$store.state.homePage);
|
||||
// }
|
||||
// })
|
||||
// .catch(function handleCaughtLoginError(error) {
|
||||
// //bad creds?
|
||||
// if (
|
||||
// error.message &&
|
||||
// error.message.includes("ErrorUserNotAuthenticated")
|
||||
// ) {
|
||||
// vm.errorBadCreds = true;
|
||||
// return;
|
||||
// }
|
||||
// //server closed by server state setting?
|
||||
// if (error.code == 2000 || error.code == 2001) {
|
||||
// vm.formState.errorBoxMessage = error.message;
|
||||
// return;
|
||||
// }
|
||||
// //probably here because server unresponsive.
|
||||
// if (error.message) {
|
||||
// let msg = error.message;
|
||||
// if (
|
||||
// msg.includes("NetworkError") ||
|
||||
// msg.includes("Failed to fetch")
|
||||
// ) {
|
||||
// msg =
|
||||
// "Could not connect to AyaNova server at " +
|
||||
// window.$gz.api.APIUrl("") +
|
||||
// "\r\nError: " +
|
||||
// error.message;
|
||||
// }
|
||||
// vm.formState.errorBoxMessage = msg;
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
|
||||
//#################################################
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -429,7 +429,7 @@ export default {
|
||||
try {
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
let res = await window.$gz.api.getEx(url);
|
||||
let res = await window.$gz.api.get(url);
|
||||
|
||||
if (res.error) {
|
||||
//Not found?
|
||||
@@ -523,7 +523,7 @@ export default {
|
||||
let url = API_BASE_URL + vm.$route.params.recordid;
|
||||
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
let res = await window.$gz.api.removeEx(url);
|
||||
let res = await window.$gz.api.remove(url);
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
|
||||
Reference in New Issue
Block a user