Module: alfresco/forms/controls/Tree

alfresco/forms/controls/Tree

This form control wraps a navigation tree in order to allow users to select a value from within a tree like structure. In order to popuplate the tree it is necessary to set the "optionsConfig.publishTopic" configuration to publish a topic that will result in data being requested for the children of each tree node expanded.

The value of the control will be either the selected object or the property of the selected item defined by the valueProperty

Since:
  • 1.0.39
Author:
  • Dave Draper
License:
Source:

Example

Example configuration

{
  id: "CLOUD_SYNC_CONTAINER",
  name: "alfresco/forms/controls/Tree",
  config: {
    fieldId: "CLOUD_SYNC_CONTAINER",
    name: "targetFolderNodeRef",
    label: "cloud-sync.dialog.path.label",
    valueProperty: "nodeRef",
    optionsConfig: {
       publishTopic: topics.GET_FORM_VALUE_DEPENDENT_OPTIONS,
       publishPayload: {
          publishTopic: topics.GET_CLOUD_PATH
       },
       publishGlobal: false
    },
  }
},

Members

_treeNodeSelectedTopic :string

This will be assigned a UUID value by the createFormControl and used to publish the selection of nodes in the tree.
Type:
  • string
Default Value:
  • null
Source:

valueProperty :string

The value to retrieve from the selected tree node. If left as null then the entire selected object will be used as the value.
Type:
  • string
Default Value:
  • null
Source:

Methods

createFormControl(config)

Sets up the subscriptions to handling tree node selection and then calls createTree to create the tree to be used as the form control.
Parameters:
Name Type Description
config object The configuration to use when instantiating the form control
Source:

createTree() → {object}

This creates a new tree.
Source:
Returns:
A new tree instance
Type
object

getPubSubOptions(config)

Overrides the inherited function to destroy any existing tree and then re-create it. This is necessary because new options effectively mean a new tree. The tree is only destroyed if it already exists to accomodate the form control creation workflow.
Parameters:
Name Type Description
config object The options config (which is ignored)
Source:

getValue() → {boolean}

Gets the value of the currently selected node in the tree.
Source:
Returns:
The checked state of the checkbox
Type
boolean

getWidgetConfig()

Source:

onTreeNodeSelected(payload)

This function is called whenever the user selects a node in the tree. It calls onValueChangeEvent to ensure that the form value is updated and can be validated (and potentially trigger changes in other fields).
Parameters:
Name Type Description
payload object The selected tree node value.
Source:

setupChangeEvents()

Overrides the inherited function to make it a no-op. All value handling is done by onTreeNodeSelected
Source:

setValue(value)

Currently it is not possible to set a tree node value.
Parameters:
Name Type Description
value object The value to set.
Source: