This commit is contained in:
2019-04-08 17:09:35 +00:00
parent 3400b9de3f
commit fa360f03b3
11 changed files with 94 additions and 73 deletions

View File

@@ -158,12 +158,13 @@ export default {
"WidgetCustom15",
"WidgetCustom16"
];
var that = this;
this.$gzlocale
.fetch(ltKeysRequired)
.then(() => (this.formReady = true))
.catch(err => {
this.formReady = true;
this.$gzerror(err);
that.$gzHandleFormError(err);
});
},
created() {
@@ -174,7 +175,7 @@ export default {
return {
obj: {},
serverError: {},
errorBoxMessage:null,
errorBoxMessage: null,
formReady: false
};
},
@@ -184,9 +185,15 @@ export default {
},
getDataFromApi() {
var url = "Widget/" + this.$route.params.id;
this.$gzapi.get(url).then(res => {
this.obj = res.data;
});
var that = this;
this.$gzapi
.get(url)
.then(res => {
this.obj = res.data;
})
.catch(function(error) {
that.$gzHandleFormError(error);
});
},
submit() {
//check if form is valid, as far as I know this is the way you're supposed to do it and in testing it does not force all fields to revalidate individually
@@ -198,24 +205,26 @@ export default {
this.$gzv.ClearServerErrors(this);
//this.$gzutil.RemoveAllPropertiesFromObject(this.serverError);
this.$gzapi.upsert(url, this.obj).then(res => {
if (res.error) {
that.serverError = res.error;
that.$gzv.SetErrorBoxErrors(that);
} else {
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.id) {
//Handle "post" of new record
that.obj = res.data;
this.$gzapi
.upsert(url, this.obj)
.then(res => {
if (res.error) {
that.serverError = res.error;
that.$gzv.SetErrorBoxErrors(that);
} else {
//Handle "put" of an existing record
that.obj.concurrencyToken = res.data.concurrencyToken;
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.id) {
//Handle "post" of new record
that.obj = res.data;
} else {
//Handle "put" of an existing record
that.obj.concurrencyToken = res.data.concurrencyToken;
}
}
}
});
//In theory all exceptions should be handled by the gzapi methods, so we should not need to deal with this in the form very often if at all
// .catch(function(error) {
// });
})
.catch(function(error) {
that.$gzHandleFormError(error);
});
} else {
//say something so the user knows there is an issue
alert("STUB: You can't do that, there are broken rules");

View File

@@ -44,7 +44,7 @@ export default {
.then(() => (this.formReady = true))
.catch(err => {
this.formReady = true;
this.$gzerror(err);
this.$gzHandleFormError(err);
});
},
components: {

View File

@@ -21,7 +21,7 @@ export default {
.then(() => (this.formReady = true))
.catch(err => {
this.formReady = true;
this.$gzerror(err);
this.$gzHandleFormError(err);
});
},
data() {