This commit is contained in:
2019-03-07 18:30:53 +00:00
parent c3020ac34a
commit 399143cc70
5 changed files with 26 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ export default {
// }
if (info) {
msg += "\ninfo: " + info;
}
}
dealWithError(msg);
},
handleVueWarning(wmsg, vm, trace) {
@@ -48,5 +48,13 @@ export default {
msg += "\ntrace: " + trace;
}
dealWithError(msg);
},
handleFormError(err) {
//called inside forms when things go wrong but are handled
if (err instanceof Error && err.message) {
dealWithError(err.message);
} else {
dealWithError(err.toString());
}
}
};

View File

@@ -12,7 +12,8 @@ export default {
return store.state.localeText[key];
},
fetch(keys) {
return new Promise(function(resolve, reject) {
return new Promise(function(resolve) {
//, reject
//step 1: build an array of keys that we don't have already
//Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
var needIt = [];
@@ -21,11 +22,14 @@ export default {
needIt.push(keys[i]);
}
}
if (keys[0] == "Log") {
throw new Error("TEST ERROR IN LOCALE");
}
if (needIt.length == 0) {
resolve();
return;
}
//step 2: get it
fetch(apiUtil.APIUrl("locale/subset"), apiUtil.fetchPostOptions(needIt))
.then(apiUtil.status)
@@ -34,11 +38,12 @@ export default {
_.forEach(response.data, function(item) {
store.commit("addLocaleText", item);
});
resolve();
})
.catch(function(error) {
reject(error);
});
// .catch(function(error) {
// reject(error);
// });
});
},
//Keys that all edit forms have in common (saves retyping them over and over)

View File

@@ -25,6 +25,9 @@ Object.defineProperty(Vue.prototype, "$dayjs", { value: dayjs });
Object.defineProperty(Vue.prototype, "$_", { value: lodash });
Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi });
Object.defineProperty(Vue.prototype, "$gzerror", {
value: errorHandler.handleFormError
});
/////////////////////////////////////////////////////////////////
// FORM VALIDATION

View File

@@ -8,7 +8,7 @@
</template>
<script>
/* Xeslint-disable */
/* eslint-disable */
export default {
created() {
var outText = "";
@@ -16,13 +16,13 @@ export default {
outText += value + "\n";
});
this.logText = outText;
this.$gzlocale
.fetch(["Log"])
.then(() => (this.formReady = true))
.catch(err => {
this.formReady = true;
throw err;
this.$gzerror(err);
//throw err;
});
},
data() {