cleanup res.error overly complex

This commit is contained in:
2020-04-09 22:45:05 +00:00
parent baadc9c3c2
commit ae3baeb954
13 changed files with 32 additions and 34 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {