This commit is contained in:
@@ -332,9 +332,9 @@ export default {
|
|||||||
throw "DEV ERROR gzform::serverErrors -> appError seems to be missing from form's vue data object";
|
throw "DEV ERROR gzform::serverErrors -> appError seems to be missing from form's vue data object";
|
||||||
}
|
}
|
||||||
|
|
||||||
//make sure errorBoxMessage is defined on data
|
//make sure formState.errorBoxMessage is defined on data
|
||||||
if (!vm.$_.has(vm, "errorBoxMessage")) {
|
if (!vm.$_.has(vm, "formState.errorBoxMessage")) {
|
||||||
throw "DEV ERROR gzform::serverErrors -> errorBoxMessage seems to be missing from form's vue data object";
|
throw "DEV ERROR gzform::serverErrors -> formState.errorBoxMessage seems to be missing from form's vue data object";
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure the error returned is in an expected format to catch coding errors at the server end
|
//ensure the error returned is in an expected format to catch coding errors at the server end
|
||||||
@@ -415,7 +415,7 @@ export default {
|
|||||||
//clear app errors
|
//clear app errors
|
||||||
vm.appError = null;
|
vm.appError = null;
|
||||||
//clear out actual message box display
|
//clear out actual message box display
|
||||||
vm.errorBoxMessage = null;
|
vm.formState.errorBoxMessage = null;
|
||||||
//Update the form status
|
//Update the form status
|
||||||
this.setFormState({
|
this.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
@@ -429,7 +429,7 @@ export default {
|
|||||||
setErrorBoxErrors(vm) {
|
setErrorBoxErrors(vm) {
|
||||||
var errs = this.serverErrors(vm, "errorbox");
|
var errs = this.serverErrors(vm, "errorbox");
|
||||||
var ret = getErrorBoxErrors(vm, errs);
|
var ret = getErrorBoxErrors(vm, errs);
|
||||||
vm.errorBoxMessage = ret;
|
vm.formState.errorBoxMessage = ret;
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// On onChange handler
|
// On onChange handler
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
<v-flex xs12 mt-1 mb-2>
|
<v-flex xs12 mt-1 mb-2>
|
||||||
<v-alert
|
<v-alert
|
||||||
ref="errorbox"
|
ref="errorbox"
|
||||||
v-show="errorBoxMessage"
|
v-show="formState.errorBoxMessage"
|
||||||
color="error"
|
color="error"
|
||||||
icon="fa-exclamation-circle "
|
icon="fa-exclamation-circle "
|
||||||
value="true"
|
value="true"
|
||||||
transition="scale-transition"
|
transition="scale-transition"
|
||||||
class="multi-line"
|
class="multi-line"
|
||||||
outline
|
outline
|
||||||
>{{errorBoxMessage}}</v-alert>
|
>{{formState.errorBoxMessage}}</v-alert>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@@ -252,31 +252,33 @@ export default {
|
|||||||
return {
|
return {
|
||||||
obj: {},
|
obj: {},
|
||||||
serverError: {},
|
serverError: {},
|
||||||
errorBoxMessage: null,
|
|
||||||
appError: null,
|
appError: null,
|
||||||
formState: {
|
formState: {
|
||||||
ready: false,
|
ready: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
valid: true,
|
valid: true,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
loading: true
|
loading: true,
|
||||||
|
errorBoxMessage: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
// ,
|
||||||
canSave: {
|
// watch: {
|
||||||
// xeslint-disable-next-line
|
// canSave: {
|
||||||
handler: function(newState) {
|
// // xeslint-disable-next-line
|
||||||
this.$gzevent.$emit(
|
// handler: function(newState) {
|
||||||
"menu-replace-item",
|
// this.$gzevent.$emit(
|
||||||
"inventory-widget-edit:save",
|
// "menu-replace-item",
|
||||||
newState
|
// "inventory-widget-edit:save",
|
||||||
);
|
// newState
|
||||||
//todo: change the save button state here
|
// );
|
||||||
//console.log("Valid CHANGED, was " + oldObj + " Now is " + newObj);
|
// //todo: change the save button state here
|
||||||
}
|
// //console.log("Valid CHANGED, was " + oldObj + " Now is " + newObj);
|
||||||
}
|
// }
|
||||||
},
|
// }
|
||||||
|
// },
|
||||||
computed: {
|
computed: {
|
||||||
canSave: function() {
|
canSave: function() {
|
||||||
return this.formState.valid && this.formState.dirty;
|
return this.formState.valid && this.formState.dirty;
|
||||||
@@ -320,8 +322,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
submit() {
|
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
|
if (this.canSave) {
|
||||||
if (this.canSave()) {
|
|
||||||
this.formState.loading = true;
|
this.formState.loading = true;
|
||||||
var vm = this;
|
var vm = this;
|
||||||
var url = "Widget/" + this.$route.params.id;
|
var url = "Widget/" + this.$route.params.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user