62
62
watch: {
63
63
// new model loaded
64
64
model : function (newModel , oldModel ) {
65
- if (oldModel == newModel) // model got a new property
65
+ if (oldModel == newModel) // model got a new property, skip
66
66
return ;
67
67
68
- // console.log(" Model changed!");
68
+ // Model changed!
69
69
if (this .options .validateAfterLoad === true && this .isNewModel !== true )
70
70
this .validate ();
71
71
else
74
74
},
75
75
76
76
compiled () {
77
- // First load
77
+ // First load, running validation if neccessary
78
78
if (this .options && this .options .validateAfterLoad === true && this .isNewModel !== true )
79
79
this .validate ();
80
80
else
81
81
this .clearValidationErrors ();
82
82
},
83
83
84
84
methods: {
85
+ // Get style classes of field
85
86
getFieldRowClasses (field ) {
86
87
let baseClasses = {
87
88
error: field .errors && field .errors .length > 0 ,
@@ -103,10 +104,12 @@ div
103
104
return baseClasses;
104
105
},
105
106
107
+ // Get type of field 'field-xxx'. It'll be the name of HTML element
106
108
getFieldType (fieldSchema ) {
107
109
return " field-" + fieldSchema .type ;
108
110
},
109
111
112
+ // Get disabled attr of field
110
113
fieldDisabled (field ) {
111
114
if (isFunction (field .disabled ))
112
115
return field .disabled (this .model );
117
120
return field .disabled ;
118
121
},
119
122
123
+ // Get visible prop of field
120
124
fieldVisible (field ) {
121
125
if (isFunction (field .visible ))
122
126
return field .visible (this .model );
127
131
return field .visible ;
128
132
},
129
133
134
+ // Validating the model properties
130
135
validate () {
131
136
this .clearValidationErrors ();
132
137
146
151
return this .errors .length == 0 ;
147
152
},
148
153
154
+ // Clear validation errors
149
155
clearValidationErrors () {
150
156
this .errors .splice (0 );
151
157
0 commit comments