smebberson/linz — pull request #28 by sandytrinh (2014-06-17 04:36:52+00:00)
Title: Added ability to define canEdit and canDelete on a model record level.

This PR adds the ability to define if a record can be edited or deleted in the formtool.
By default formtool will assume all records can be edited and deleted unless a canEdit or canDelete function is defined as methods against the model. Below is an example of a canDelete function:

```
userSchema.methods.canDelete = function (callback) {

// canDelete logics here ...

// if record cannot be deleted
return callback(null, false, 'Cannot delete!');

// if record can be deleted, no message is require in the third parameter
return callback(null, true);
}
```

If canEdit or canDelete returns false, a message is required as the third parament. This message will be added as ```data-``` attribute against the markup of the corresponding edit or delete button. This message will then be rendered via javascript to omit the message upon clicking the button to alert user why a particular record cannot be deleted.