6262 watch: {
6363 // new model loaded
6464 model : function (newModel , oldModel ) {
65- if (oldModel == newModel) // model got a new property
65+ if (oldModel == newModel) // model got a new property, skip
6666 return ;
6767
68- // console.log(" Model changed!");
68+ // Model changed!
6969 if (this .options .validateAfterLoad === true && this .isNewModel !== true )
7070 this .validate ();
7171 else
7474 },
7575
7676 compiled () {
77- // First load
77+ // First load, running validation if neccessary
7878 if (this .options && this .options .validateAfterLoad === true && this .isNewModel !== true )
7979 this .validate ();
8080 else
8181 this .clearValidationErrors ();
8282 },
8383
8484 methods: {
85+ // Get style classes of field
8586 getFieldRowClasses (field ) {
8687 let baseClasses = {
8788 error: field .errors && field .errors .length > 0 ,
@@ -103,10 +104,12 @@ div
103104 return baseClasses;
104105 },
105106
107+ // Get type of field 'field-xxx'. It'll be the name of HTML element
106108 getFieldType (fieldSchema ) {
107109 return " field-" + fieldSchema .type ;
108110 },
109111
112+ // Get disabled attr of field
110113 fieldDisabled (field ) {
111114 if (isFunction (field .disabled ))
112115 return field .disabled (this .model );
117120 return field .disabled ;
118121 },
119122
123+ // Get visible prop of field
120124 fieldVisible (field ) {
121125 if (isFunction (field .visible ))
122126 return field .visible (this .model );
127131 return field .visible ;
128132 },
129133
134+ // Validating the model properties
130135 validate () {
131136 this .clearValidationErrors ();
132137
146151 return this .errors .length == 0 ;
147152 },
148153
154+ // Clear validation errors
149155 clearValidationErrors () {
150156 this .errors .splice (0 );
151157
0 commit comments