Module: alfresco/forms/controls/Picker

alfresco/forms/controls/Picker

This is the root widget that should be extended for all "picker" controls. By default it will effectively render a Document Picker (as this was the original picker module that the code was abstracted from) but extending pickers (such as the Container Picker and the Property Picker) can change the display of picked items and the behaviour of the picker itself by overriding the configForPickedItems and configForPicker respectively. Pickers are designed to be used in forms to allow the user to select multiple "complex items".

Author:
  • Dave Draper
License:
Source:

Members

configForPickedItems :object

This should be overridden to define the widget model for rendering the picked items.
Type:
  • object
Default Value:
  • []
Source:

configForPicker :object

This should be overridden to define the widget model for rendering the picker that appears within the dialog.
Type:
  • object
Default Value:
  • []
Source:

dialogPickedItemsProperty :string

This is the dot-notation property address where to find the picked items from the dialog that was displayed. It can be overridden as necessary.
Type:
  • string
Default Value:
  • "pickedItemsWidget.currentData.items"
Source:

i18nRequirements :Array

An array of the i18n files to use with this widget.
Type:
  • Array
Source:

itemKey :string

The value to use as a key for each item. Each picked item should have an attribute with the name defined.
Type:
  • string
Default Value:
  • "name"
Source:

pickerWidget :string

This is the widget to use as the root picker.
Type:
  • string
Default Value:
  • "alfresco/pickers/Picker"
Source:

useCurrentItemAsValue :boolean

Whether to use the currentItem as the initial value of the picker
Type:
  • boolean
Default Value:
  • false
Source:

widgetsForControl :object

Type:
  • object
Source:

Methods

createFormControl(config)

Overrides the inherited function to create the picked items display and the picker itself. This should not need to be overridden by extending pickers.
Parameters:
Name Type Description
config object The configuration object for instantiating the picker form control
Source:

getPickedItemsWidget() → {object}

Retrieves the PickedItems widget defined in the widgetsForControl model. This is defined in a separate function to support functions that override the model and need to obtain the widget by a different means.
Source:
Returns:
Type
object

getValue() → {object}

The value returned is an array where each element is the value of the itemKey of each item returned by calling the getPickedItemsWidget function.
Source:
Returns:
Type
object

getWidgetConfig()

Source:

onItemsSelected(payload)

This is called when the form generated by the AlfFormDialogButton is submitted. The payload will contain the picked items captured by the Picker widget. The items should then be rendered in the local PickedItems widget.
Parameters:
Name Type Description
payload object The details of the selected items
Source:

processPickedItems(pickedItems)

Called from the onItemsSelected when items have been picked. This will update the current view of the picked items widget and validate the form control.
Parameters:
Name Type Description
pickedItems object[] The picked items to process
Since:
  • 1.0.36
Source:

setModelPickedItemsConfig(config, value, widgetsForControl)

Updates the model to set a value of the currently selected items. It is necessary to do this because the model cannot contain variable information (at least none that can be defined when the widget is instantiated) so it is necessary to perform this before the processWidgets function is called.
Parameters:
Name Type Description
config object The configuration to use
value array The value to set
widgetsForControl object A cloned copy of the defined widgets for the picked items
Source:

setModelPickerConfig(value)

Updates the model to set a value of the currently selected items. It is necessary to do this because the model cannot contain variable information (at least none that can be defined when the widget is instantiated) so it is necessary to perform this before the processWidgets function is called.
Parameters:
Name Type Description
value object The value to set
Source:

setModelPickerWidgetValue(value)

Updates the model to set a value of the currently selected items. It is necessary to do this because the model cannot contain variable information (at least none that can be defined when the widget is instantiated) so it is necessary to perform this before the processWidgets function is called.
Parameters:
Name Type Description
value object The value to set
Source:

setValue(value)

Calls the setModelPickerWidgetValue function.
Parameters:
Name Type Description
value object
Source:

startup()

Run after widget and all children created
Source:

updateFormDialogButton(value)

When items are picked it is necessary to update the AlfFormDialogButton that generates the form containing the Picker because the DialogService will destroy the dialog when it is closed.
Parameters:
Name Type Description
value object The items to set.
Source: