UBEntity

UBEntity

new UBEntity(entityInfo, entityMethods, i18n, entityCode, domain)

Arguments:
  1. entityInfo (Object)
  2. entityMethods (Object)
  3. i18n (Object)
  4. entityCode (String)
  5. domain (UBDomain)

Members

domain: UBDomain readonly

code: String readonly

attributes: Object.<string, UBEntityAttribute>

Entity attributes collection

mixins: Object.<String, UBEntityMixin>

Collection of entity mixins

entityMethods: Object.<String, Number> readonly

Entity methods, allowed for current logged-in user in format {method1: 1, method2: 1}. 1 mean method is allowed

caption: string

Entity caption

description: string

Entity description

documentation: string

Documentation

descriptionAttribute: string

Name of attribute witch used as a display value in lookup

cacheType: String readonly

Indicate how entity content is cached on the client side.

Possible cache types: None, "None", "Entity", "Session", "SessionEntity"

Methods

getEntityCaption()string

Return an entity caption to display on UI

attr(attributeCode, simpleopt)UBEntityAttribute

Get entity attribute by code. Return undefined if attribute does not found
Arguments:
  1. attributeCode (String)
  2. [simple] (Boolean)  Is do not complex attribute name. By default false.

getAttribute(attributeCode)UBEntityAttribute

Get entity attribute by code. Throw error if attribute does not found.
Arguments:
  1. attributeCode

eachAttribute(callBack, scopeopt)

Call collBack function for each attribute.
Arguments:
  1. callBack (function)
  2. [scope] (Object)

mixin(mixinCode)UBEntityMixin

Get entity mixin by code. Returns "undefined" if the mixin is not found
Arguments:
  1. mixinCode (String)

hasMixin(mixinCode)Boolean

Check the entity has mixin. Returns true if the mixin is exist and enabled
Arguments:
  1. mixinCode (String)

checkMixin(mixinCode)

Check the entity has mixin. Throw error if mixin dose not exist or not enabled
Arguments:
  1. mixinCode (String)

filterAttribute(config)Array

Filter attributes by properties
Arguments:
  1. config (Object|function)

haveAccessToMethod(methodCode)Boolean

Check current user have access to specified entity method
Arguments:
  1. methodCode (String)

haveAccessToAnyMethods(methods)boolean

Check current user have access to AT LAST one of specified methods
Arguments:
  1. methods (Array)

haveAccessToMethods(Method)Boolean

Check current user have access to ALL of specified methods
Arguments:
  1. Method (Array.<String>)  names

getConvertRules(fieldList) → Array.<{index: number, convertFn: function()}>

return array of conversion rules for raw server response data
Arguments:
  1. fieldList (Array.<String>)

getDescriptionAttribute()String

Return description attribute name (descriptionAttribute metadata property) This property may be empty or valid(validation performed by server) If case property is empty - try to get attribute with code caption

getEntityAttributeInfo(attributeName, deepopt)Object

Return information about attribute and attribute entity. Understand complex attributes like firmID.firmType.code
Arguments:
  1. attributeName (String)
  2. [deep] (Number)  If 0 - last, -1 - before last, > 0 - root. Default 0.

getEntityAttribute(attributeName, deepopt)UBEntityAttribute

Return Entity attribute. Understand complex attributes like firmID.firmType.code
Arguments:
  1. attributeName (String)
  2. [deep] (Number)  If 0 - last, -1 - before last, > 0 - root. Default 0.

getAttributeNames(filteropt)

return attributes code list
Arguments:
  1. [filter] (Object|function)

getEntityRequirements(fieldListopt) → Array.<String>

Return requirements entity code list for field list
Arguments:
  1. [fieldList] (Array.<String>)  (optional)

checkAttributeExist(attributeName, contextMessage)

Check the entity contains attribute(s) and throw error if not contains
Arguments:
  1. attributeName (String|Array.<String>)
  2. contextMessage (String)

getEntityDescription()string

Return entity description.