APIs

Show:
Extends Helper Usage: templates/my-form.hbs `handlebars {!-- Without custom "path" keyword (default keyword "path" will be used) --} {{flexberry-tree nodes=(get-with-dynamic-actions this "treeNodes" hierarchyPropertyName="nodes" dynamicActions=(array (hash on="headerClick" actionName="onTreenodeHeaderClick" actionArguments=(array "{% path %}") ) (hash on="checkboxChange" actionName="onTreenodeCheckboxChange" actionArguments=(array "{% path %}.checkboxValue") ) ) ) }} {{!-- With custom "path" keyword --}} {{flexberry-tree nodes=(get-with-dynamic-actions this "treeNodes" hierarchyPropertyName="nodes" pathKeyword="nodePath" dynamicActions=(array (hash on="headerClick" actionName="onTreenodeHeaderClick" actionArguments=(array "{% nodePath %}") ) (hash on="checkboxChange" actionName="onTreenodeCheckboxChange" actionArguments=(array "{% nodePath %}.checkboxValue") ) ) ) }} ` controllers/my-form.js `javascript import Controller from '@ember/controller'; import TreeNodeObject from 'ember-flexberry/objects/flexberry-treenode'; export default Controller.extend({ treeNodes: A( FlexberryTreenodeObject.create({ caption: 'Node 1 (with child nodes)', hasCheckbox: true, checkboxValue: false, iconClass: 'map icon', nodes: A([ caption: 'Node 1.1 (leaf node)', hasCheckbox: true, checkboxValue: false, iconClass: 'apple icon', nodes: null ) }), FlexberryTreenodeObject.create({ caption: 'Node 2 (leaf node)', hasCheckbox: true, checkboxValue: false, iconClass: 'compass icon', nodes: null }) ]), actions: { onTreenodeHeaderClick(...args) { let treeNodePath = args[0]; let treeNodeHeaderClickActionEventObject = args[args.length - 1]; console.log('Clicked tree node\'s properties:', this.get(treeNodePath)); console.log('Clicked tree node\'s \'headerClick\' action event object:', treeNodeHeaderClickActionEventObject); }, onTreenodeCheckboxChange(...args) { let treeNodeCheckboxValuePath = args[0]; let treeNodeCheckboxChangeActionEventObject = args[args.length - 1]; // Change tree node's 'checkboxValue' property. this.set(treeNodeCheckboxValuePath, treeNodeCheckboxChangeActionEventObject.newValue); } } }); `
Module: ember-flexberry

Get with dynamic actions helper. Retrieves property with the specified name from the specified object (exactly as standard get helper does), and additionally binds dynamic actions for retrieved property's nested object/objects (even if retrieved property has hierarchical structure).

Helper must be used with those component's, which consumes their inner structure as JSON-object or EmberObject and there is no way to attach action handlers for their nested component's explicitly in hbs-markup.

Methods

_addHierarchyPropertyObserver

(
  • propertyPath
)
private

Adds observer for given hierarchy property, which will force helper to recompute on any changes in the specified hierarchy property.

Parameters:

  • propertyPath String

    Path to observable property.

_bindDynamicActions

(
  • propertyValue
  • propertyPath
  • Name
  • Specified
)
private

Binds given dynamic actions to every object in the specified hierarchy.

Parameters:

  • propertyValue Object | Object[]

    Value of some property in the specified hierarchy.

  • propertyPath String

    Path to property in the specified hierarchy.

  • Name String

    of property that leads to nested child properties in the specified hierarchy.

  • Specified DynamicAction

    dynamic actions.

_removeHierarchyPropertiesObservers

(
  • options
)
private

Removes all previously attached to hierarchy properties observers.

Parameters:

  • options Object

    Method options.

    • propertyPath String

      Path to property from which observers must be removed.

    • propertyPathStartsWith String

      Prefix of path to properties from which observers must be removed.

_renamePropertyPath

(
  • observerPropertyPath
  • len
)
private

Renames property path of observers.

Parameters:

  • observerPropertyPath String

    Path to property from which observers must be removed.

  • len Number

    Index of observer in the array to be removed.

_sort

(
  • hierarchyPropertiesObservers
)
private

Sort array with hierarchy properties observers.

Parameters:

  • hierarchyPropertiesObservers Array

    Array with hierarchy properties observers.

compute

(
  • args
  • [hash] Object containing [helper's named arguments]
  • [hash.hierarchyPropertyName]
  • [hash.dynamicActions]
)
Object | Object[]

Overridden Helper compute method. Executes helper's logic, returns helper's value.

Parameters:

  • args Any
    • 0 Object

      Property owner, object containing property which must be retrieved & returned from helper (after dynamic action binding). Will be also used as action handlers context (if context wasn't specified explicitly in dynamic action bindings).

    • 1 String

      Name of those property which must be retrieved from owner & returned from helper (after dynamic actions binding). Owner's property (behind this name) must be an object or array of objects.

  • [hash] Object containing [helper's named arguments] Object
  • [hash.hierarchyPropertyName] Object optional

    Name of nested property (inside retrieved one), through which child object/objects (objects hierarchy) will be available.

  • [hash.dynamicActions] DynamicActionObject[] optional

    Dynamic actions, which will be binded to object/objects retrieved from the owner (and to all nested child objects).

Returns:

Object | Object[]:

Retrieved object/objects with binded dynamic actions (including nested child objects).

Properties

_dynamicActions

DynamicActionObject[] private

Dynamic actions, which will be binded to object/objects retrieved from the owner (and to all nested child objects).

_hierarchyPropertiesObservers

Object[] private

Array with objects containing names of hierarchy properties and observer handlers related to them. Each object in array has following structure: { propertyPath: '...', observerHandler: function() { ... } }.

Default: null

_hierarchyPropertyName

String private

Name of nested property (inside retrieved one), through which child object/objects (objects hierarchy) is/are available.

_rootPropertyName

String private

Name of those property which must be retrieved from owner & returned from helper (after dynamic actions binding).

_rootPropertyOwner

Object private

Owner of hierarchy root property.

Default: null