settings.settingsCollection Class
/var/www/azaleahealth.com/branches/docs/source_repo/awa/resources/apps/js/settings/settingsCollection.js:3
Collection that holds models that generate the proper view given the correct category and id.
The object then has a function that takes a set of args and returns a properly configured view.
In the callback function, you should pull any needed models (i.e. user, role, etc)
before returning the view.
Below is an example of a view generating object
//new section view
new awa.mvc.Model({
//category that it fits in
set_category: "general",
//unique section, use [model]list for grid views and [model] for detail and edit views.
set_id: "locations",
//returns if the user in the current should have access to this section
condition: function(){
return awa.func.client_access("upr_location_list");
},
//the section callback should check permissions, grab the necessary item,
//return an awa.mvc.ContentView based on the passed in args.
//Be sure to use the awa.mvc.ContentView to get the full benefits of the controls bar
//and title as well as automatic scrolling.
set_section: function(sectionConfig){
awa.data.getStore("Locations").get(sectionConfig.id, function (location) {
if(sectionConfig.state != 'edit'){
sectionConfig.callback(new LocationDetailsView({
loc_id: sectionConfig.id,
location: location,
state: sectionConfig.state}));
} else {
sectionConfig.callback(new LocationEditView({
loc_id: sectionConfig.id,
location: location,
state: sectionConfig.state}));
}
});
}
}));
//--ccarroll: To hide a menu option from non-ahi personnel or otherwise, //provide a condition: function() that returns an access //boolean value (see 'encryption' for precedent)
Item Index
Methods
- _logLastUpdatedOnSync
- addFilter deprecated
- addParams
- addReturnColumn
- canDoLocalQuery
- clearFilters
- displayMethod
- fetchAll
- fetchTotalRows
- filterReject
- findWhere
- get
- getArgument
- getDisplay
- getDisplayMethod
- getFetchData
- getFilters
- getLimit
- getName
- getOffset
- getOrderBy
- getParam
- getParams
- getQuery
- getReturnColumns
- getSortBy
- hasAPIPagination
- idAttribute
- isFetchingTotalRows
- load
- onQuery
- save
- setArgument
- setArguments
- setFilter
- setFilters
- setLimit
- setOffset
- setOrderBy
- setParam
- setParams
- setQuery
- setReturnColumns
- setSortBy
- sync
- toDisplayJSON
- toJSON
- where
Properties
Events
Methods
_logLastUpdatedOnSync
()
Undefined
When sync is triggered, this method updates the lastUpdated value
Returns:
undefined
addFilter
-
attr -
comp -
val
Parameters:
-
attrStringfilter to add
-
compStringcomparator to use (> < = != IN BETWEEN)
-
valString | Arrayfilter to add
Returns:
this
addParams
-
params
Adds hashmap params to current params
Parameters:
-
paramsObjectFull parameter set
Returns:
this
addReturnColumn
-
col
Adds a column to the collection option for the return that is sent to the server on fetch.
Parameters:
-
colStringattribute to return
Returns:
this
canDoLocalQuery
()
Boolean
Returns:
Can locally query
clearFilters
()
awa.mvc.Collection
chainable
Clears all collection filters
Returns:
this
displayMethod
-
val -
id -
source
Parameters:
-
valStringValue
-
idStringAttribute id
-
sourceawa.mvc.Collection | awa.mvc.ModelSource collection or model
Returns:
brief string summary of the collection as a whole
fetchAll
-
[options]
Gets all of the collection records. Returns a promise that is already resolved if cache is available. Cleared with reset.
Parameters:
-
[options]Object optionalxhr options. Use the other methods instead
Returns:
promise for when fetch is complete
fetchTotalRows
-
get_total_rows
Instructs server to calculate total row count
Parameters:
-
get_total_rowsBooleanFlag
Returns:
this
filterReject
-
predicate
A version of reject to return a modified version of this collection.
Parameters:
-
predicateFunctionA function that returns true when an item should be removed from the collection. It takes one argument, the model it should test against. Defaults to _.noop
Returns:
This collection without models rejected by predicate.
findWhere
-
[list] -
props
Overridden version of findWhere to be less typesafe. ID changes from string or int based on if model is new which causes several issues when doing a search
Parameters:
-
[list]Array optionalnot used
-
propsObjectProperties to match against
Returns:
returns matches model
get
-
attr
Get the current value of an attribute from the model Overwritten to create collections and sub models only when needed.
Parameters:
-
attrStringsupports dot notation to get properties of individual models
Returns:
model or attribute of sub model
getArgument
-
key -
filter
Gets an argument based on the key
Parameters:
-
keyStringArgument key
-
filterString | Array | Objector array of filters
Returns:
Argument value
getDisplay
-
attr
Parameters:
-
attrStringsupports dot notation to get properties of individual models
Returns:
Like get, but this uses the displayMethod.
getDisplayMethod
-
attr
Parameters:
-
attrStringattribute of model
Returns:
returns the displayMethod for a given attribute
getFetchData
()
Object
Get the entire data object {with the exception of the ahis session id} that is sent to the server.
Returns:
object fo data sent when fetching
getFilters
()
Array | Object
Gets the array of filters that is sent to the server.
Returns:
All filters
getLimit
()
Integer
Returns:
collection option for the maximum returned results that is sent to the server on fetch.
getName
-
attr
Gets the name of an attribute. This can be set by and attribute's attributeProp name. returns the attribute if not set.
Parameters:
-
attrStringattribute of model
Returns:
attribute Name of attribute
getOffset
()
Integer
Returns:
collection option for the offset that is sent to the server on fetch.
getOrderBy
()
String
Returns:
collection option for ordering that is sent to the server on fetch.
getParam
-
key
Gets a parameter that are sent to the server by key.
Parameters:
-
keyStringParamter key
Returns:
selected param
getParams
()
Object
Gets all of the parameters that are sent to the server.
Returns:
all params
getQuery
()
String | Object
Gets the collection option for searching that is sent to the server on fetch.
Returns:
Query value
getReturnColumns
()
Array
Returns:
collection option for the return that is sent to the server on fetch.
getSortBy
()
String
Returns:
collection option for sorting ascending or descending that is sent to the server on fetch. Can be ASC or DESC
hasAPIPagination
()
Boolean
Api will return meta data to indicate pagination for grids/lists. The collection will gain properties such as currentPage, nextPage, etc.
Returns:
True if api supports pagination
idAttribute
()
String
Returns:
Specifies the key/id of the models in this collection.
isFetchingTotalRows
()
Boolean
Returns:
Indicates collection will request total rows on next fetch
load
-
id -
[options]
Get the entire data object {with the exception of the ahis session id} that is sent to the server.
Parameters:
-
idInteger | Stringid of single model
-
[options]Object optionalset of options
Returns:
promise when fetch is complete
onQuery
-
query
Override this method and return a list of models if you want to implement local querying
Parameters:
-
queryStringstring to search
Returns:
query string to search
save
-
models -
options
Saves several models at a time. Not always supported by backend
Parameters:
-
modelsArrayjust pass undefined for now
-
optionsObjectconfiguration object with various properties
Returns:
sometimes its a promise
setArgument
-
key -
value
Sets one collection argument. params, options, and filters will be ignored this is the preferred way of handling "filters"
Parameters:
-
keyStringor array of filters
-
valueString | Array | Objector array of filters
Returns:
this
setArguments
-
obj
Sets the collection arguments. This must be an object and is the preferred way of handling "filters" The object properties options, filters, and params will overwritten by their pre-existing values.
Parameters:
-
objObjectArgument object
Returns:
this
setFilter
-
attr -
val -
comp
Adds one filter to the array of filters that is sent to the server on fetch.
Used to accept (attr, comp, val) this has been changed for new filtering for hermes and in consideration of deprecating the old addFilter method
Parameters:
-
attrStringattribute to filter
-
valString | Arrayvalue(s) to filter
-
compStringcomparator to use "=",">",">=","<","<=","!=","~" (Only works with hermes)
Returns:
this
setFilters
-
filters
Sets the collection option for all filtering strings that is sent to the server on fetch.
Parameters:
-
filtersString | Array | Objectobject or array of filters
Returns:
this
setLimit
-
limit
Sets the collection option for the maximum returned results that is sent to the server on fetch.
Parameters:
-
limitString | Integeramount to limit by
Returns:
this
setOffset
-
offset
Sets the collection option for the offset that is sent to the server on fetch.
Parameters:
-
offsetString | Integernumber to start at in a list
Returns:
this
setOrderBy
-
order_by
Sets the collection option for ordering that is sent to the server on fetch.
Parameters:
-
order_byStringattribute to order by
Returns:
this
setParam
-
k -
v
Sets the parameter value that is sent to the server
Parameters:
-
kStringParamter key
-
vStringParamter value
Returns:
this
setParams
-
params
Sets all of the parameters that are sent to the server
Parameters:
-
paramsObjectFull parameter set
Returns:
this
setQuery
-
query
Sets the collection option for searching that is sent to the server on fetch. What this is matched against is api/controller dependent.
Parameters:
-
queryStringstring to search
Returns:
this
setReturnColumns
-
cols
Sets the collection option for the return that is sent to the server on fetch.
Parameters:
-
colsArrayArray of attributes
Returns:
this
setSortBy
-
sort_by
Sets the collection option for sorting ascending or descending that is sent to the server on fetch. Can be ASC or DESC
Parameters:
-
sort_byStringattribute to sort by
Returns:
this
sync
-
method -
collection -
options
Overridden from Backbone.Collection.fetch to handle not so restful backend.
Parameters:
-
methodStringread update or create
-
collectionawa.mvc.Collectioncollection this is called on
-
optionsObjectxhr options
Returns:
sometimes its a promise
toDisplayJSON
()
Array
Uses the displayRules/Methods that are set in either the displayRules property or the attributeProps to generate a javascript object (w/o getters and setters) that represents the model's data in a displayable format.
Returns:
array of objects
toJSON
-
options
Override of collections toJSON to handle empty indexes
Parameters:
-
optionsObjectconfiguration object with various properties
Returns:
array of objects
where
-
props
Overridden version of where to be less typesafe and to handle undefined. ID changes from string or int based on if model is new which causes several issues when doing a search
Parameters:
-
propsObjectconfiguration object with various properties to match on
Returns:
returns array of matched models
Properties
_localCache
Boolean
Default: false
api
String
Default: barebones
controller
awa.mvc.View | Object
Used to prevent developers from sharing collections among grids.
Default: undefined
lastUpdated
Date
Default: null
Events
filters
Gets an argument based on the key
Event Payload:
-
sourceawa.mvc.CollectionThis collection
-
argsObjectobject of arguments
-
filtersObjectObject of current filters
-