This commit is contained in:
@@ -159,7 +159,7 @@ export default {
|
||||
|
||||
//Vuetify seems to prioritize messages over validation rule messages or perhaps it's set to display only one at a time no matter what value is set for error-count
|
||||
//What I need is each field needs to bind here
|
||||
//This code needs to determine if there are any errors for the field in question,
|
||||
//This code needs to determine if there are any errors for the field in question,
|
||||
//and return the appropriate string of text
|
||||
//Then eventually this needs to go into gzvalidate as part of *it's* code so I can just easily call that shit from anywhere
|
||||
|
||||
@@ -169,7 +169,20 @@ export default {
|
||||
// - how many are field related and how many are general?
|
||||
//- what is best for the end user and least confusing? (probably error with field unless it's general then at top and cleared instantly when they modify the field in question)
|
||||
|
||||
//IN ADDITION: on submit needs to clear serverErrors
|
||||
//IN ADDITION: on submit needs to clear serverErrors
|
||||
|
||||
/*
|
||||
Steps to completion:
|
||||
|
||||
On submit show server errors for fields in their fields, show general errors at the top of form in an error box
|
||||
When a field is edited any *server* errors must clear for that field right away
|
||||
When the form is submitted all server errors cleared if any from previous submit
|
||||
|
||||
|
||||
//example error when submit when there are no roles set at all (blank)
|
||||
//{"error":{"code":"2200","details":[{"code":"2200","message":"","target":"roles","error":"VALIDATION_FAILED"}],"message":"Object did not pass validation"}}
|
||||
|
||||
*/
|
||||
|
||||
if (this.$_.isEmpty(this.serverErrors)) return [];
|
||||
|
||||
@@ -194,31 +207,27 @@ export default {
|
||||
},
|
||||
submit() {
|
||||
// debugger;
|
||||
//Submit the form data to the api
|
||||
|
||||
//Check for broken rules, do not submit with broken rules
|
||||
//No broken rules then:
|
||||
//Gather up the form data into a submitable object (can I just submit the existing object??)
|
||||
//Post it
|
||||
//Update the local object with the returned result
|
||||
//Check the return object for broken rules
|
||||
//TODO: CHECK FOR BROKEN RULES AND DON'T SUBMIT IF THERE ARE ANY HERE
|
||||
|
||||
var that = this;
|
||||
var url = "Widget/" + this.$route.params.id;
|
||||
//clear any errors that might be around from previous submit
|
||||
this.serverErrors = [];
|
||||
this.$gzapi
|
||||
.upsert(url, this.obj)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
//debugger;
|
||||
//Set errors so form can pick them up for controls in canHasServerErrors
|
||||
that.serverErrors = res.error;
|
||||
// that.$refs.form.resetValidation();
|
||||
// that.$refs.form.validate();
|
||||
//example error when submit when there are no roles set at all (blank)
|
||||
//{"error":{"code":"2200","details":[{"code":"2200","message":"","target":"roles","error":"VALIDATION_FAILED"}],"message":"Object did not pass validation"}}
|
||||
//todo: integrate validation error into form so user can see it
|
||||
//User can only submit if no existing errors so should be starting with a clean error free form and then will see validation errors under appropriate fields
|
||||
//if a user makes a change to a control then that control being changed should remove the rule from the server until the next submit happens
|
||||
|
||||
} else {
|
||||
//Logic for detecing if a post or put: if id then it was a post, if no id then it was a put
|
||||
//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;
|
||||
|
||||
Reference in New Issue
Block a user