Class: EditableChildCollection

EditableChildCollection

Represents the definition of an asynchronous editable child collection.

new EditableChildCollection(parent, eventHandlers)

Creates a new asynchronous editable child collection instance.

The name of the model type available as: <instance>.constructor.modelType, returns 'EditableChildCollection'.

Valid parent model types are:

 * EditableRootModel
 * EditableChildModel
Parameters:
Name Type Argument Description
parent object

The parent business object.

eventHandlers bo.shared.EventHandlerList <optional>

The event handlers of the instance.

Throws:
Argument error: The parent object must be an EditableRootModel or EditableChildModel instance.

Extends

Members

<readonly> $modelName :string

The name of the model.

Type:
  • string

<readonly> count :number

The count of the child objects in the collection.

Type:
  • number

Methods

at(index) → {EditableChildModel}

Gets a collection item at a specific position.

Parameters:
Name Type Description
index number

The index of the required item in the collection.

Returns:

The required collection item.

Type
EditableChildModel

<protected> checkRules()

Executes validation on all items of the collection.

This method is called by the parent object.

create(index, callback)

Creates a new item and adds it to the collection at the specified index.

Parameters:
Name Type Description
index number

The index of the new item.

callback external.cbDataPortal

Returns the newly created editable business object.

every(callback) → {boolean}

Tests whether all items in the collection pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

True when callback returns truthy value for each item, otherwise false.

Type
boolean

<protected> fetch(data, callback)

Initializes the items in the collection with data retrieved from the repository.

This method is called by the parent object.

Parameters:
Name Type Argument Description
data Array.<object> <optional>

The data to load into the business object collection.

callback external.cbDataPortal

Returns the eventual error.

filter(callback) → {Array.<EditableChildModel>}

Creates a new array with all collection items that pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

The new array of collection items.

Type
Array.<EditableChildModel>

forEach(callback)

Executes a provided function once per collection item.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function that produces an item of the new collection.

fromCto(data, callback)

Rebuilds the business object collection from a plain object array sent by the client.
This method is usually called by the parent object.

Parameters:
Name Type Description
data Array.<object>

The array of client transfer objects.

callback external.cbFromCto

Returns the eventual error.

<protected> getBrokenRules(namespace) → {Array.<bo.rules.BrokenRulesOutput>}

Gets the broken rules of all items of the collection.

This method is called by the parent object.

Parameters:
Name Type Argument Description
namespace string <optional>

The namespace of the message keys when messages are localizable.

Returns:

The broken rules of the collection.

Type
Array.<bo.rules.BrokenRulesOutput>

<protected> isValid() → {boolean}

Indicates whether all items of the business collection are valid.

This method is called by the parent object.

Returns:
Type
boolean

map(callback) → {Array.<*>}

Creates a new array with the results of calling a provided function on every item in this collection.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

The new array of callback results.

Type
Array.<*>

remove()

Marks all items in the collection to be deleted from the repository on next save.

<protected> save(connection, callback)

Saves the changes of the business object collection to the repository.

This method is called by the parent object.

Parameters:
Name Type Description
connection object

The connection data.

callback external.cbDataPortal

Returns the eventual error.

some(callback) → {boolean}

Tests whether some item in the collection pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

True when callback returns truthy value for some item, otherwise false.

Type
boolean

sort(fnCompare) → {EditableChildCollection}

Sorts the items of the collection in place and returns the collection.

Parameters:
Name Type Argument Description
fnCompare external.cbCompare <optional>

Function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each item.

Returns:

The sorted collection.

Type
EditableChildCollection

toCto() → {Array.<object>}

Transforms the business object collection to a plain object array to send to the client.
This method is usually called by the parent object.

Returns:

The client transfer object.

Type
Array.<object>
If you find bugs or have feature requests, please let us know.

JavaScript business objects ♦ Copyright © 2014-2016 Logikum, Ltd.
Documentation generated by JSDoc 3.2.2 on 2015. December 31. using the DocStrap template.