@@ -75,8 +75,7 @@ export default {
75
75
76
76
formOptions: {
77
77
validateAfterLoad: true ,
78
- validateAfterChanged: true ,
79
- validateBeforeSave: true
78
+ validateAfterChanged: true
80
79
}
81
80
};
82
81
},
@@ -118,7 +117,7 @@ export default {
118
117
},
119
118
120
119
onValidated (res , errors ) {
121
- console .log (" VFG validated:" , res, errors);
120
+ console .log (" onValidated VFG validated:" , arguments , res, errors);
122
121
},
123
122
124
123
generateModel () {
@@ -145,32 +144,36 @@ export default {
145
144
},
146
145
147
146
saveModel () {
148
- console .log (" Save model..." );
149
- if (this .formOptions .validateBeforeSave === false || this .validate ()) {
150
- this .mergeModelValues ();
151
-
152
- if (this .isNewModel ) {
153
- this .rows .push (this .model );
154
- this .selectRow (null , this .model , false );
147
+ console .log (" Save model..." , this .validate , typeof this .validate );
148
+ this .validate ().then (
149
+ (test ) => {
150
+ console .log (" saveModel" , test);
151
+ this .mergeModelValues ();
152
+
153
+ if (this .isNewModel ) {
154
+ this .rows .push (this .model );
155
+ this .selectRow (null , this .model , false );
156
+ }
157
+ },
158
+ (error ) => {
159
+ // Validation error
160
+ console .warn (" Error saving model..." , error);
155
161
}
156
- } else {
157
- console .warn (" Error saving model..." );
158
- // Validation error
159
- }
162
+ );
160
163
},
161
164
162
165
mergeModelValues () {
163
166
let model = this .model ;
164
167
if (model && this .selected .length > 0 ) {
165
- each (this .selected , row => {
168
+ each (this .selected , ( row ) => {
166
169
merge (row, model);
167
170
});
168
171
}
169
172
},
170
173
171
174
deleteModel () {
172
175
if (this .selected .length > 0 ) {
173
- each (this .selected , row => {
176
+ each (this .selected , ( row ) => {
174
177
let index = this .rows .indexOf (row);
175
178
this .rows .splice (index, 1 );
176
179
});
@@ -181,15 +184,16 @@ export default {
181
184
getNextID () {
182
185
let id = 0 ;
183
186
184
- each (this .rows , row => {
187
+ each (this .rows , ( row ) => {
185
188
if (row .id > id) id = row .id ;
186
189
});
187
190
188
191
return ++ id;
189
192
},
190
193
191
194
validate () {
192
- // console.log("validate", this.$refs.form, this.$refs.form.validate());
195
+ console .log (" APP validate" , this .$refs .form , typeof this .$refs .form .validate );
196
+
193
197
return this .$refs .form .validate ();
194
198
},
195
199
@@ -199,7 +203,7 @@ export default {
199
203
200
204
getLocation (model ) {
201
205
if (navigator .geolocation ) {
202
- navigator .geolocation .getCurrentPosition (pos => {
206
+ navigator .geolocation .getCurrentPosition (( pos ) => {
203
207
if (! model .address ) model .address = {};
204
208
if (! model .address .geo ) model .address .geo = {};
205
209
model .address .geo .latitude = pos .coords .latitude .toFixed (5 );
0 commit comments