cleanup res.error overly complex
This commit is contained in:
@@ -49,10 +49,8 @@ CURRENT TODOs
|
||||
|
||||
@@@@@@@@@@@ ROADMAP STAGE 2:
|
||||
|
||||
todo: widgets list form needs search link
|
||||
|
||||
todo: if (res.error != undefined) could be changed to if(res.error) everywhere
|
||||
todo: what is vm.loading used for?
|
||||
- generally preventing a loading a second time, but it's not checked for at the start in all cases so need to pick through and ensure that
|
||||
|
||||
todo: RECORD HISTORY
|
||||
- implement in stubbed out separate page
|
||||
|
||||
@@ -744,7 +744,7 @@ export default function initialize() {
|
||||
.get("UserOptions/" + window.$gz.store.state.userId)
|
||||
// eslint-disable-next-line
|
||||
.then((res) => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
//In a form this would trigger a bunch of validation or error display code but for here and now:
|
||||
//convert error to human readable string for display and popup a notification to user
|
||||
let msg = window.$gz.api.apiErrorToHumanString(res.error);
|
||||
@@ -799,7 +799,7 @@ export default function initialize() {
|
||||
.get("GlobalBizSettings/client")
|
||||
// eslint-disable-next-line
|
||||
.then((res) => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
//In a form this would trigger a bunch of validation or error display code but for here and now:
|
||||
//convert error to human readable string for display and popup a notification to user
|
||||
let msg = window.$gz.api.apiErrorToHumanString(res.error);
|
||||
|
||||
@@ -518,7 +518,7 @@ export default {
|
||||
listView: untokenizedListView
|
||||
})
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
} else {
|
||||
//NOTE: This is how to call an async function and await it from sync code
|
||||
@@ -774,7 +774,7 @@ function populateSelectionLists(vm) {
|
||||
return window.$gz.api
|
||||
.get("DataListView/ViewList?ListKey=" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
vm.selectLists.listViews = res.data;
|
||||
@@ -792,7 +792,7 @@ function fetchListView(vm) {
|
||||
return;
|
||||
}
|
||||
return window.$gz.api.get("DataListView/" + vm.listViewId).then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
vm.listView = res.data.listView;
|
||||
|
||||
@@ -251,7 +251,7 @@ export default {
|
||||
window.$gz.api
|
||||
.get(API_BASE_URL + "ListFields/" + vm.templateId)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -267,7 +267,7 @@ export default {
|
||||
//weirdly, this wasn't working properly until I put it in a function, it was just executing immediately before translations were resolved from fetch above
|
||||
//get current edited template
|
||||
window.$gz.api.get(API_BASE_URL + vm.templateId).then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -321,7 +321,7 @@ export default {
|
||||
.upsert(url, newObj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -352,7 +352,7 @@ export default {
|
||||
window.$gz.api
|
||||
.remove(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -471,7 +471,7 @@ function fetchTranslatedText(vm) {
|
||||
//
|
||||
function populateSelectionLists(vm) {
|
||||
return window.$gz.api.get(API_BASE_URL + "List").then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
vm.selectLists.pickListTemplates = res.data;
|
||||
|
||||
@@ -301,7 +301,7 @@ function fetchTranslatedText(vm) {
|
||||
//
|
||||
function getServerInfo(vm) {
|
||||
return window.$gz.api.get("ServerInfo").then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.serverInfo = res.data;
|
||||
|
||||
@@ -198,7 +198,7 @@ export default {
|
||||
.upsert(url, newObj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
|
||||
@@ -731,7 +731,7 @@ export default {
|
||||
.upsert(url, lvSave)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -798,7 +798,7 @@ export default {
|
||||
window.$gz.api
|
||||
.remove(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -845,7 +845,7 @@ export default {
|
||||
.then(res => {
|
||||
// debugger;
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -1184,7 +1184,7 @@ function populateFieldDefinitions(vm) {
|
||||
return window.$gz.api
|
||||
.get("DataList/ListFields?DataListKey=" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.fieldDefinitions = res.data;
|
||||
@@ -1241,7 +1241,7 @@ function setEffectiveListView(vm) {
|
||||
return window.$gz.api
|
||||
.get("DataListView/default/" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = JSON.parse(res.data);
|
||||
@@ -1251,7 +1251,7 @@ function setEffectiveListView(vm) {
|
||||
} else {
|
||||
//listview has an id value
|
||||
return window.$gz.api.get("DataListView/" + vm.listViewId).then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = JSON.parse(res.data.listView);
|
||||
|
||||
@@ -205,7 +205,7 @@ export default {
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
|
||||
@@ -227,7 +227,7 @@ export default {
|
||||
max
|
||||
)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -280,7 +280,7 @@ export default {
|
||||
})
|
||||
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
|
||||
@@ -244,7 +244,7 @@ export default {
|
||||
window.$gz.api
|
||||
.get(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
//Not found?
|
||||
if (res.error.code == "2010") {
|
||||
//notify not found error then navigate backwards
|
||||
@@ -297,7 +297,7 @@ export default {
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -439,7 +439,7 @@ function fetchTranslatedText(vm) {
|
||||
function populateSelectionLists(vm) {
|
||||
//http://localhost:7575/api/v8/Translation/List
|
||||
return window.$gz.api.get("Translation/List").then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
vm.selectLists.translations = res.data;
|
||||
|
||||
@@ -325,7 +325,7 @@ export default {
|
||||
// // .then(res => {
|
||||
// // debugger;
|
||||
// // vm.formState.ready = true;
|
||||
// // if (res.error != undefined) {
|
||||
// // if (res.error) {
|
||||
// // vm.formState.serverError = res.error;
|
||||
// // window.$gz.form.setErrorBoxErrors(vm);
|
||||
// // } else {
|
||||
|
||||
@@ -145,7 +145,7 @@ export default {
|
||||
.get(url)
|
||||
.then(res => {
|
||||
vm.formState.ready = true;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -184,7 +184,7 @@ export default {
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
|
||||
@@ -387,7 +387,7 @@ export default {
|
||||
window.$gz.api
|
||||
.get(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
//Not found?
|
||||
if (res.error.code == "2010") {
|
||||
//notify not found error then navigate backwards
|
||||
@@ -438,7 +438,7 @@ export default {
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -488,7 +488,7 @@ export default {
|
||||
window.$gz.api
|
||||
.remove(url)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
@@ -525,7 +525,7 @@ export default {
|
||||
.then(res => {
|
||||
// debugger;
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user