This commit is contained in:
2020-11-26 19:46:52 +00:00
parent f26579103e
commit 649e817086
10 changed files with 75 additions and 33 deletions

View File

@@ -95,7 +95,8 @@ export default {
let res = await window.$gz.api.get("enum-list/list/" + enumKey);
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
// throw new Error(res);
return Promise.reject(res);
}
return res.data;
}

View File

@@ -32,7 +32,7 @@ function dealWithError(msg, vm) {
let errMsg = "DEV MODE errorHandler.js:: Unexpected error: \r\n" + msg;
// eslint-disable-next-line no-console
console.error(errMsg);
//console.trace();
//debugger;
}
@@ -68,8 +68,16 @@ function dealWithError(msg, vm) {
// and return human readable text
//
function decodeError(e, vm) {
// console.log("decodeError The e object is an object:");
// //console.log(JSON.stringify(e));
// console.log(typeof e === "object");
//empty?
if (e == null || e == "") {
if (
e == null ||
e == "" ||
(typeof e === "object" && Object.keys(e).length === 0)
) {
return "errorHandler::decodeError - Error is unknown / empty";
}

View File

@@ -271,7 +271,8 @@ export default {
vm.fetching = false;
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
//throw new Error(res);
return Promise.reject(res);
}
vm.searchResults = res.data;
window.$gz.form.addNoSelectionItem(vm.searchResults, true);

View File

@@ -174,7 +174,7 @@ export default new Router({
import(/* webpackChunkName: "cust" */ "./views/cust-customer-notes.vue")
},
{
path: "/cust-customer-notes/:customerid/:recordid",
path: "/cust-customer-note/:recordid",
name: "customer-note-edit",
component: () =>
import(/* webpackChunkName: "cust" */ "./views/cust-customer-note.vue")

View File

@@ -589,14 +589,16 @@ async function initForm(vm) {
let res = await window.$gz.api.get("license");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
return Promise.reject(res);
//throw new Error(res);
}
vm.currentLicenseInfo = res.data.license;
res = await window.$gz.api.get("license/database-empty");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
return Promise.reject(res);
//throw new Error(res);
}
vm.dbIsEmpty = res.data;
}

View File

@@ -305,7 +305,8 @@ async function getServerInfo(vm) {
let res = await window.$gz.api.get("server-info");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
//throw new Error(res);
return Promise.reject(res);
} else {
vm.serverInfo = res.data;
}

View File

@@ -205,7 +205,8 @@ export default {
let res = await window.$gz.api.get("license/database-empty");
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
return Promise.reject(res);
//throw new Error(res);
}
if (res.data != true) {
let dialogResult = await window.$gz.dialog.confirmGeneric(

View File

@@ -1186,7 +1186,8 @@ async function fetchReportData(vm) {
let res = await window.$gz.api.upsert("report/data", reportDataOptions);
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
throw new Error(res);
return Promise.reject(res);
//throw new Error(res);
} else {
vm.reportData = res.data;
}

View File

@@ -7,7 +7,7 @@
<v-row>
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-col cols="12" v-if="customername">
{{ customername }}
<v-btn @click="goToCustomer"> {{ customername }}</v-btn>
</v-col>
<v-col cols="12">
<v-textarea
@@ -93,6 +93,11 @@ export default {
});
} else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
if (!vm.customername) {
await fetchCustomerName(vm).catch(err => {
window.$gz.errorHandler.handleFormError(err, vm);
});
}
}
} else {
vm.obj.customerId = this.$route.params.customerid;
@@ -188,6 +193,15 @@ export default {
}
},
methods: {
goToCustomer() {
this.$router.push({
name: "customer-edit",
params: {
recordid: this.obj.customerId
}
});
},
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
@@ -233,6 +247,7 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.obj = res.data;
//modify the menu as necessary
generateMenu(vm);
//Update the form status
@@ -502,8 +517,29 @@ async function initForm(vm) {
// Ensures UI translated text is available
//
async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations(["CustomerNoteNotes"]);
await window.$gz.translation.cacheTranslations([
"CustomerNoteNotes",
"CustomerNoteNoteDate"
]);
}
///////////////////////////////////////////////////////////
//
//
async function fetchCustomerName(vm) {
//If customer name is missing then fetch it here to display
//this will happen when this form is directly opened from a search
//or record history etc
let res = await window.$gz.api.get(
`name/${window.$gz.type.Customer}/${vm.obj.customerId}`
);
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
return Promise.reject(res);
} else {
vm.customername = res.data;
}
}
</script>
<style></style>