User lists now working properly with datalist. Fixup for many areas where error constructor was being called with object instead of string

This commit is contained in:
2020-12-08 20:25:55 +00:00
parent 0b7f418c11
commit 9f0ef1a8f5
19 changed files with 68 additions and 60 deletions

View File

@@ -5,28 +5,6 @@
MISC ITEMS THAT CAME UP
todo: customer users and regular users really need to reconsider not using a standard grid,
seeded huge basically dies waiting
However, how real is that scenario in the first place?
Ideally though for many reasons it should be a regular datagrid
Look into it, find out why it isn't and can it be implemented?
Also roles could then show on the customer-user grid which would be handy for some
AT LEAST put a wait spinner on that page
ACTIONS:
XMake a snapshot commit at both ends tagged with the fact about to do mucho fuckery and may need to revert
XMake copies of gz-data-table.js and inv-parts.vue
Xmake a InsideUserDataList.cs at server
XModify inv-parts.vue to show the insideuserdatalist in a gz-data-table
Xwork on gz-data-table and attempt to have roles work, use the code in adm-users rolesDisplayFromRoles method
FieldDataType=17 for roles
XSee if can get it to work adequately without worrying about filtering on roles
XNOPE, doesn't offer to filter, only sort and I'm happy with it for now.If it basically is working well enough regardless of filtering roles then see if its even conceivable that server could filter roles
maybe the client sends a lot of or i.e. roles = (64 or 1234 or 32768) however that shit has to work
if conceivable then need to make a copy of the ay-data-list-view.vue and modify to work with roles as a filter
XMake sure can print, bulk ops etc
If all is well then move it into the regular adm-users and replicate to cust-users and ditch the shitty current half-ass grid
Remove the routes that were being used for inside and outside user lists as they are no longer reqd.
$profit
todo: throw new Error() code *MUST* put only a string into the constructor of error. Putting a object is wrong and will result in errors that say "Error: [object Object]"
Search for all instances of throw new Error and ensure it's a string not an object, use stringify if necessary when all else fails

View File

@@ -95,7 +95,6 @@ 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);
return Promise.reject(res);
}
return res.data;

View File

@@ -24,7 +24,7 @@ export default {
//fetch and populate the store
let res = await window.$gz.api.get("form-custom/" + formKey);
if (res.error) {
throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
}
window.$gz.store.commit("setFormCustomTemplateItem", {
formKey: formKey,

View File

@@ -503,7 +503,8 @@ export default {
handleError("UPSERT", error, route);
} else {
//specifically this is for the login page
throw new Error(error);
// throw new Error(error);
throw new Error(window.$gz.errorHandler.errorToString(res));
}
}
},
@@ -694,7 +695,8 @@ export default {
let res = await window.$gz.api.upsert("report/render", reportDataOptions);
if (res.error) {
throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res));
//throw new Error(res.error);
} else {
let reportUrl = window.$gz.api.reportDownloadUrl(res.data);
if (redirectNotPopup) {

View File

@@ -730,7 +730,8 @@ async function getUserOptions() {
"logItem",
"Initialize::() fetch useroptions -> error" + error
);
throw new Error(error);
// throw new Error(error);
throw new Error(window.$gz.errorHandler.errorToString(res));
}
}

View File

@@ -21,7 +21,8 @@ export default {
if (keepChecking && window.$gz.store.state.authenticated) {
status = await window.$gz.api.get("notify/new-count");
if (status.error) {
throw new Error(status.error);
throw new Error(window.$gz.errorHandler.errorToString(status));
// throw new Error(status.error);
} else {
window.$gz.store.commit("setNewNotificationCount", status.data);
//success so go to default in case it was changed by an error

View File

@@ -62,7 +62,10 @@ export default {
"user/inside-type/" + tid.id
);
if (res.error) {
throw new Error(res.error);
//throw new Error(res.error);
throw new Error(
window.$gz.errorHandler.errorToString(res, vm)
);
}
if (res.data) {
tid.inside = res.data;
@@ -80,7 +83,8 @@ export default {
});
}
} catch (e) {
throw new Error(e);
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
//throw new Error(e);
}
})();
}
@@ -100,14 +104,16 @@ export default {
let res = await window.$gz.api.get("attachment/parent/" + tid.id);
if (res.error) {
throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
// throw new Error(res.error);
}
if (res.data.id && res.data.id != 0) {
this.handleOpenObjectClick(vm, res.data);
return;
}
} catch (e) {
throw new Error(e);
//throw new Error(e);
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
}
})();
@@ -146,7 +152,8 @@ export default {
);
if (res.error) {
throw new Error(res.error);
//throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
}
if (res && res.data) {
vm.$router.push({
@@ -156,7 +163,8 @@ export default {
return;
}
} catch (e) {
throw new Error(e);
//throw new Error(e);
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
}
})();

View File

@@ -93,7 +93,8 @@ export default {
//call api route
let jobId = await window.$gz.api.upsert(url, body);
if (jobId.error) {
throw new Error(jobId.error);
//throw new Error(jobId.error);
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
}
jobId = jobId.jobId; //it's in a sub key
//indicate loading by setting on button
@@ -120,7 +121,10 @@ export default {
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw new Error(jobStatus.error);
//throw new Error(jobStatus.error);
throw new Error(
window.$gz.errorHandler.errorToString(jobStatus, vm)
);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {

View File

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

View File

@@ -134,7 +134,8 @@ export default {
`report/list/${reportDataOptions.ObjectType}`
);
if (res.error) {
throw new Error(res.error);
// throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} else {
this.reportList = res.data;
}

View File

@@ -204,7 +204,8 @@ export default {
//call seed route
let jobId = await window.$gz.api.upsert("attachment/maintenance");
if (jobId.error) {
throw new Error(jobId.error);
//throw new Error(jobId.error);
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
}
jobId = jobId.jobId; //it's in a sub key
vm.jobActive = true;
@@ -230,7 +231,10 @@ export default {
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw new Error(jobStatus.error);
// throw new Error(jobStatus.error);
throw new Error(
window.$gz.errorHandler.errorToString(jobStatus, vm)
);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {

View File

@@ -388,11 +388,13 @@ export default {
//send request
r = await window.$gz.api.upsert("license/trialRequest", vm.request);
if (r.error) {
throw new Error(r);
//throw new Error(r);
throw new Error(window.$gz.errorHandler.errorToString(r, vm));
}
//a string is returned and will start with E1 if it's an error
if (r.startsWith("E1")) {
throw new Error(r);
throw new Error(window.$gz.errorHandler.errorToString(r, vm));
//throw new Error(r);
}
if (r == "ok") {
@@ -414,7 +416,10 @@ export default {
//It might have been just installed by the server on it's own so check if we are not working with the most current license
let currentServerLicenseInfo = await window.$gz.api.get("license");
if (currentServerLicenseInfo.error) {
throw new Error(currentServerLicenseInfo.error);
//throw new Error(currentServerLicenseInfo.error);
throw new Error(
window.$gz.errorHandler.errorToString(currentServerLicenseInfo, vm)
);
}
currentServerLicenseInfo = currentServerLicenseInfo.data.license;
@@ -433,11 +438,13 @@ export default {
let r = await window.$gz.api.upsert("license");
//r should just be a string response unless there is an error in which case it's an object
if (r.error) {
throw new Error(r);
// throw new Error(r);
throw new Error(window.$gz.errorHandler.errorToString(r, vm));
}
if (r.startsWith("E1")) {
throw new Error(r);
//throw new Error(r);
throw new Error(window.$gz.errorHandler.errorToString(r, vm));
}
//If here, there is no technical error
//key might not exist or be not found but no error so r contains the deets
@@ -590,7 +597,6 @@ async function initForm(vm) {
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
return Promise.reject(res);
//throw new Error(res);
}
vm.currentLicenseInfo = res.data.license;
@@ -598,7 +604,6 @@ async function initForm(vm) {
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
return Promise.reject(res);
//throw new Error(res);
}
vm.dbIsEmpty = res.data;
}

View File

@@ -305,7 +305,6 @@ 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);
return Promise.reject(res);
} else {
vm.serverInfo = res.data;

View File

@@ -377,7 +377,8 @@ async function initDataObject(vm) {
let url = "form-field-definition/" + vm.$route.params.formCustomTemplateKey;
let res = await window.$gz.api.get(url);
if (res.error) {
throw new Error(res.error);
//throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
}
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form
// - {key, ltdisplay, hideable, custom, required, hide, type}

View File

@@ -1203,7 +1203,8 @@ async function populateFieldDefinitions(vm) {
"data-list/listfields?DataListKey=" + vm.dataListKey
);
if (res.error) {
throw new Error(res.error);
//throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} else {
vm.fieldDefinitions = res.data;
}
@@ -1259,7 +1260,8 @@ async function setEffectiveListView(vm) {
);
if (res.error) {
throw new Error(res.error);
// throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} else {
vm.effectiveListView = JSON.parse(res.data);
vm.obj.name = vm.$ay.t("FilterUnsaved");
@@ -1268,7 +1270,8 @@ async function setEffectiveListView(vm) {
//listview has an id value
let res = await window.$gz.api.get("data-list-view/" + vm.listViewId);
if (res.error) {
throw new Error(res.error);
//throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} else {
vm.effectiveListView = JSON.parse(res.data.listView);
vm.obj.public = res.data.public;

View File

@@ -203,7 +203,6 @@ export default {
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
return Promise.reject(res);
//throw new Error(res);
}
if (res.data != true) {
let dialogResult = await window.$gz.dialog.confirmGeneric(
@@ -233,7 +232,8 @@ export default {
`trial/seed/${vm.obj.seedLevel}/${vm.obj.timeZoneOffset}`
);
if (jobId.error) {
throw new Error(jobId.error);
//throw new Error(jobId.error);
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
}
jobId = jobId.jobId; //it's in a sub key
//indicate loading by setting on button
@@ -260,7 +260,10 @@ export default {
`job-operations/status/${jobId}`
);
if (jobStatus.error) {
throw new Error(jobStatus.error);
//throw new Error(jobStatus.error);
throw new Error(
window.$gz.errorHandler.errorToString(jobStatus, vm)
);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {

View File

@@ -1172,7 +1172,6 @@ async function fetchReportData(vm) {
//We never expect there to be no data here
if (!res.hasOwnProperty("data")) {
return Promise.reject(res);
//throw new Error(res);
} else {
vm.reportData = res.data;
}

View File

@@ -215,7 +215,8 @@ export default {
//this is to ensure that when a user is viewing the latest notifications they don't see the NEW count still in the bell icon in menu since they are viewing them live
let status = await window.$gz.api.get("notify/new-count");
if (status.error) {
throw new Error(status.error);
//throw new Error(status.error);
throw new Error(window.$gz.errorHandler.errorToString(status, vm));
}
window.$gz.store.commit("setNewNotificationCount", status.data);
}

View File

@@ -383,7 +383,6 @@ export default {
//move focus to password
document.getElementsByName("password")[0].focus();
},
async login() {
let vm = this;
if (vm.input.username != "" && vm.input.password != "") {
@@ -403,7 +402,8 @@ export default {
if (res.error) {
//don't expect this to ever get called but just in case
throw new Error(res.error);
// throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
}
await processLogin(res.data, loggedInWithKnownPassword);