awa.mvc.ModelAttributeTypes.ModelAttributeType Class
Defined in:
Module: awa.mvc.ModelAttributeTypes
/var/www/azaleahealth.com/branches/docs/source_repo/awa/resources/apps/js/awa/mvc/ModelAttributeTypes.js:10
ModelAttributeTypes are used in conjunction with the model to enhance the functionality of individual attributes.
Below shows a persisted attribute and a derived attribute using the universal properties that all attribute types support
//persisted attribute
pat_dob:{
//Intended for developers, provides realtime information about am attribute
//Mostly used for attributes that are added to models outside of their own file
//i.e. {medical.PatientsProblemModel}
_info: "I'm helping!",
// maps to a possible attribute type
// The default assumption is string type
type: 'date',
// human readable name of property
name: 'DOB',
// function that returns a displayable string
// keep in mind you do not have to define a function here.
// You can pass a function as a property
// Also, some types provide a default displayMethod for convenience
// The function is passed (rawValue, attributeKey, model)
// the rawValue is the only guaranteed parameter, some uses of displayMethod
// may not provider the 2nd and 3rd param
displayMethod: awa.func.date_format_simple,
// even though this is a date type attribute, the rule
// is required for proper warnings.
// Some inputs will enfore the rule type regardless of the rule.
// For possible rules, see {awa.mvc.ModelRules}
rules: {
date: true
}
},
//derived attribute
pat_ext_id: {
//this is an array of attributes to trigger off of
//The model will not build the attribute until atleast 1 is present
on: ['pat_cus_id', 'pat_cli_id', 'pat_id'],
//this function receives the RAW attribute BEFORE they are set
//use these to build the value
build: function(attributes){
return attributes.pat_cus_id+'-'+attributes.pat_cli_id+'-'+attributes.pat_id;
},
//this ensures that the property will not be sent back to the server
sync: false
},