APIs

Show:

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",

    //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){
        if(!client_access("upr_location_list")){
            restricted("Locations");
        }else{
            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

Methods

_logLastUpdatedOnSync

() Undefined

When sync is triggered, this method updates the lastUpdated value

Returns:

Undefined:

undefined

addFilter

(
  • attr
  • comp
  • val
)
awa.mvc.Collection deprecated chainable

Inherited from awa.mvc.Collection: /var/www/azaleahealth.com/branches/docs/source_repo/awa/resources/apps/js/awa/mvc/Collection.js:674

Deprecated: Using this means you are using string based filter and that is bad Remove when all string based filters are gone Adds one filter to the array of filters that is sent to the server on fetch.

Parameters:

  • attr String

    filter to add

  • comp String

    comparator to use (> < = != IN BETWEEN)

  • val String | Array

    filter to add

Returns:

addParams

(
  • params
)
awa.mvc.Collection chainable

Adds hashmap params to current params

Parameters:

  • params Object

    Full parameter set

Returns:

addReturnColumn

(
  • col
)
awa.mvc.Collection chainable

Adds a column to the collection option for the return that is sent to the server on fetch.

Parameters:

  • col String

    attribute to return

Returns:

canDoLocalQuery

() Boolean

Returns:

Boolean:

Can locally query

displayMethod

(
  • val
  • id
  • source
)
String

Parameters:

Returns:

String:

brief string summary of the collection as a whole

fetchAll

(
  • [options]
)
Promise

Gets all of the collection records. Returns a promise that is already resolved if cache is available. Cleared with reset.

Parameters:

  • [options] Object optional

    xhr options. Use the other methods instead

Returns:

Promise:

promise for when fetch is complete

fetchTotalRows

(
  • get_total_rows
)
awa.mvc.Collection chainable

Instructs server to calculate total row count

Parameters:

  • get_total_rows Boolean

    Flag

Returns:

filterReject

(
  • predicate
)
awa.mvc.Collection

A version of reject to return a modified version of this collection.

Parameters:

  • predicate Function

    A 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:

awa.mvc.Collection:

This collection without models rejected by predicate.

findWhere

(
  • [list]
  • props
)
awa.mvc.Model

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 optional

    not used

  • props Object

    Properties to match against

Returns:

awa.mvc.Model:

returns matches model

get

(
  • attr
)
Mixed

Get the current value of an attribute from the model Overwritten to create collections and sub models only when needed.

Parameters:

  • attr String

    supports dot notation to get properties of individual models

Returns:

Mixed:

model or attribute of sub model

getArgument

(
  • key
  • filter
)
String | Array | Object

Gets an argument based on the key

Parameters:

  • key String

    Argument key

  • filter String | Array | Object

    or array of filters

Returns:

String | Array | Object:

Argument value

getDisplay

(
  • attr
)
Mixed

Parameters:

  • attr String

    supports dot notation to get properties of individual models

Returns:

Mixed:

Like get, but this uses the displayMethod.

getDisplayMethod

(
  • attr
)
Function

Parameters:

  • attr String

    attribute of model

Returns:

Function:

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:

object fo data sent when fetching

getFilters

() Array | Object

Gets the array of filters that is sent to the server.

Returns:

Array | Object:

All filters

getLimit

() Integer

Returns:

Integer:

collection option for the maximum returned results that is sent to the server on fetch.

getName

(
  • attr
)
String

Gets the name of an attribute. This can be set by and attribute's attributeProp name. returns the attribute if not set.

Parameters:

  • attr String

    attribute of model

Returns:

String:

attribute Name of attribute

getOffset

() Integer

Returns:

Integer:

collection option for the offset that is sent to the server on fetch.

getOrderBy

() String

Returns:

String:

collection option for ordering that is sent to the server on fetch.

getParam

(
  • key
)
Mixed

Gets a parameter that are sent to the server by key.

Parameters:

  • key String

    Paramter key

Returns:

Mixed:

selected param

getParams

() Object

Gets all of the parameters that are sent to the server.

Returns:

Object:

all params

getQuery

() String | Object

Gets the collection option for searching that is sent to the server on fetch.

Returns:

String | Object:

Query value

getReturnColumns

() Array

Returns:

Array:

collection option for the return that is sent to the server on fetch.

getSortBy

() String

Returns:

String:

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:

Boolean:

True if api supports pagination

idAttribute

() String

Returns:

String:

Specifies the key/id of the models in this collection.

isFetchingTotalRows

() Boolean

Returns:

Boolean:

Indicates collection will request total rows on next fetch

load

(
  • id
  • [options]
)
Promise

Get the entire data object {with the exception of the ahis session id} that is sent to the server.

Parameters:

  • id Integer | String

    id of single model

  • [options] Object optional

    set of options

Returns:

Promise:

promise when fetch is complete

onQuery

(
  • query
)
Array

Override this method and return a list of models if you want to implement local querying

Parameters:

  • query String

    string to search

Returns:

Array:

query string to search

save

(
  • models
  • options
)
Promise

Saves several models at a time. Not always supported by backend

Parameters:

  • models Array

    just pass undefined for now

  • options Object

    configuration object with various properties

Returns:

Promise:

sometimes its a promise

setArgument

(
  • key
  • value
)
awa.mvc.Collection chainable

Sets one collection argument. params, options, and filters will be ignored this is the preferred way of handling "filters"

Parameters:

  • key String

    or array of filters

  • value String | Array | Object

    or array of filters

Returns:

setArguments

(
  • obj
)
awa.mvc.Collection chainable

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:

  • obj Object

    Argument object

Returns:

setFilter

(
  • attr
  • val
  • comp
)
awa.mvc.Collection chainable

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:

  • attr String

    attribute to filter

  • val String | Array

    value(s) to filter

  • comp String

    comparator to use "=",">",">=","<","<=","!=","~" (Only works with hermes)

Returns:

setFilters

(
  • filters
)
awa.mvc.Collection chainable

Sets the collection option for all filtering strings that is sent to the server on fetch.

Parameters:

  • filters String | Array | Object

    object or array of filters

Returns:

setLimit

(
  • limit
)
awa.mvc.Collection chainable

Sets the collection option for the maximum returned results that is sent to the server on fetch.

Parameters:

  • limit String | Integer

    amount to limit by

Returns:

setOffset

(
  • offset
)
awa.mvc.Collection chainable

Sets the collection option for the offset that is sent to the server on fetch.

Parameters:

  • offset String | Integer

    number to start at in a list

Returns:

setOrderBy

(
  • order_by
)
awa.mvc.Collection chainable

Sets the collection option for ordering that is sent to the server on fetch.

Parameters:

  • order_by String

    attribute to order by

Returns:

setParam

(
  • k
  • v
)
awa.mvc.Collection chainable

Sets the parameter value that is sent to the server

Parameters:

  • k String

    Paramter key

  • v String

    Paramter value

Returns:

setParams

(
  • params
)
awa.mvc.Collection chainable

Sets all of the parameters that are sent to the server

Parameters:

  • params Object

    Full parameter set

Returns:

setQuery

(
  • query
)
awa.mvc.Collection chainable

Sets the collection option for searching that is sent to the server on fetch. What this is matched against is api/controller dependent.

Parameters:

  • query String

    string to search

Returns:

setReturnColumns

(
  • cols
)
awa.mvc.Collection chainable

Sets the collection option for the return that is sent to the server on fetch.

Parameters:

  • cols Array

    Array of attributes

Returns:

setSortBy

(
  • sort_by
)
awa.mvc.Collection chainable

Sets the collection option for sorting ascending or descending that is sent to the server on fetch. Can be ASC or DESC

Parameters:

  • sort_by String

    attribute to sort by

Returns:

sync

(
  • method
  • collection
  • options
)
Promise

Overridden from Backbone.Collection.fetch to handle not so restful backend.

Parameters:

  • method String

    read update or create

  • collection awa.mvc.Collection

    collection this is called on

  • options Object

    xhr options

Returns:

Promise:

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:

array of objects

toJSON

(
  • options
)
Array

Override of collections toJSON to handle empty indexes

Parameters:

  • options Object

    configuration object with various properties

Returns:

Array:

array of objects

where

(
  • props
)
Array

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:

  • props Object

    configuration object with various properties to match on

Returns:

Array:

returns array of matched models

Events

filters

Gets an argument based on the key

Event Payload:

  • source awa.mvc.Collection

    This collection

  • args Object

    object of arguments

    • filters Object

      Object of current filters