module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo

module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo

new (require("nmodule/webEditors/rc/wb/mgr/MgrTypeInfo"))()

Description:
  • API Status: Development

    MgrTypeInfo wraps information about what type to create
    in the station database when doing a new or add operation.
    This information may come from an exact type, a registry
    query for concrete types given a base type, or from a component
    instance used as a prototype.

    In addition to the basic type operations, this provides extra
    functionality specific to the manager views, such as the ability
    to compare and match types.

    This constructor should be not called directly. Client code should
    use the static .make() function.

Source:

Methods

equals(other) → {Boolean}

Description:
  • Equality comparison for two MgrTypeInfo instances based on a comparison
    of the display name. This will return false if the other object is not a
    MgrTypeInfo instance.

Source:
Parameters:
Name Type Description
other Object

the object to be compared against

Returns:
Type
Boolean

getDisplayName() → {String}

Description:
  • Get the display name of the type to create.

Source:
Returns:
Type
String

getIcon() → {baja.Icon}

Description:
  • Get the icon of the type to create.

Source:
Returns:
Type
baja.Icon

getType() → {baja.Type}

Description:
  • Get the BajaScript Type to be created by this MgrTypeInfo instance.

Source:
Returns:
Type
baja.Type

isMatchable(db) → {Boolean}

Description:
  • Return true if this type may be used to perform a learn match against the
    specified database component.

Source:
Parameters:
Name Type Description
db baja.Component

the database component

Returns:
Type
Boolean

newInstance() → {Promise.<baja.Component>}

Description:
  • Returns a Promise that will create a new instance of a component
    from the type information.

Source:
Returns:
Type
Promise.<baja.Component>

toSlotName() → {String}

Description:
  • Get the type as a slot name. The default implementation
    returns the display name stripped of spaces and escaped.

Source:
Returns:
Type
String

toString() → {String}

Description:
  • Returns the display name for the type represented by this instance.

Source:
Returns:
Type
String

(static) BY_DISPLAY_NAME()

Description:
  • Helper function to be passed to an array sorting function to ensure MgrTypeInfo instances are
    ordered according to the display name.

Source:
Example

Sort the array of MgrTypeInfos obtained from the make() function.

MgrTypeInfo.make({
  from: 'baja:ControlPoint',
  concreteTypes: true
})
.then(function (mgrInfos) {
  mgrInfos.sort(MgrTypeInfo.BY_DISPLAY_NAME);
});

(static) make(params) → {Promise}

Description:
  • Static .make() function, returning a Promise that will resolve
    to a single MgrTypeInfo or array of MgrTypeInfos, depending on the
    arguments passed to the function. This is the normal way to obtain a
    MgrTypeInfo instance; the type's constructor should not be used by client
    code directly.

Source:
Examples

Make an array of MgrTypeInfos from an array of type spec strings.

MgrTypeInfo.make({
  from: [ 'baja:AbsTime', 'baja:Date', 'baja.RelTime' ]
})
.then(function (mgrInfos) {
  // ... do something with the array of MgrTypeInfo
});

Get the concrete MgrTypeInfos for the abstract ControlPoint type.

MgrTypeInfo.make({
  from: 'baja:ControlPoint',
  concreteTypes: true
})
.then(function (mgrInfos) {
  // ... do something with the array of MgrTypeInfo
});

Get the MgrTypeInfos for the agents on a type

 baja.registry.getAgents("type:moduleName:TypeName")
   .then(function (agentInfos) {
     return MgrTypeInfo.make({
       from: agentInfos
     });
   })
   .then(function (mgrInfos) {
     // ... do something with the array of MgrTypeInfo
   });
Parameters:
Name Type Description
params Object

an Object containing the function's arguments

Properties
Name Type Attributes Description
from String | baja.Type | Array

The type spec used to create the
type information. This may be a single type spec string, or a BajaScript Type instance,
or may be an array of spec strings or Types.

concreteTypes Boolean <optional>

true if the from parameter should be used
as a base type to create an Array of MgrTypeInfos for its concrete types. If this parameter
is specified as true, the from parameter must contain a single base type.

batch baja.comm.Batch <optional>

An optional batch object, which if provided can be
used to batch network calls.

Returns:

Either a single MgrTypeInfo instance, or an array of MgrTypeInfos,
depending on the value passed in the 'from' parameter and the value of the 'concreteTypes'
parameter. If the 'from' parameter specifies a single type and 'concreteTypes' is either
false or undefined, the returned value will be a single MgrTypeInfo, otherwise the returned
value will be an array of MgrTypeInfos.

Type
Promise

(static) markDuplicates(infos)

Description:
  • Static function to compare an array of MgrTypeInfos for duplicate type names.
    This is used to alter the display name for any non-prototype created MgrTypeInfos,
    where there may be two or more modules exposing types with the same display names.

Source:
Parameters:
Name Type Description
infos Array.<module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo>