Skip to content

Commit

Permalink
docs: commenting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Sep 26, 2016
1 parent 307e903 commit dc17006
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ div
watch: {
// new model loaded
model: function(newModel, oldModel) {
if (oldModel == newModel) // model got a new property
if (oldModel == newModel) // model got a new property, skip
return;
//console.log("Model changed!");
// Model changed!
if (this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
Expand All @@ -74,14 +74,15 @@ div
},
compiled() {
// First load
// First load, running validation if neccessary
if (this.options && this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
},
methods: {
// Get style classes of field
getFieldRowClasses(field) {
let baseClasses = {
error: field.errors && field.errors.length > 0,
Expand All @@ -103,10 +104,12 @@ div
return baseClasses;
},
// Get type of field 'field-xxx'. It'll be the name of HTML element
getFieldType(fieldSchema) {
return "field-" + fieldSchema.type;
},
// Get disabled attr of field
fieldDisabled(field) {
if (isFunction(field.disabled))
return field.disabled(this.model);
Expand All @@ -117,6 +120,7 @@ div
return field.disabled;
},
// Get visible prop of field
fieldVisible(field) {
if (isFunction(field.visible))
return field.visible(this.model);
Expand All @@ -127,6 +131,7 @@ div
return field.visible;
},
// Validating the model properties
validate() {
this.clearValidationErrors();
Expand All @@ -146,6 +151,7 @@ div
return this.errors.length == 0;
},
// Clear validation errors
clearValidationErrors() {
this.errors.splice(0);
Expand Down

0 comments on commit dc17006

Please sign in to comment.