This is the inner controls used by the
MultiSelectInput form control.
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Extends
Mixes In
Members
-
_currentSearchValue :string
-
A cache of the current search value
Type:
- string
- Source:
-
_disabled :boolean
-
Whether the control is disabled
Type:
- boolean
- Source:
-
_focusedResult :module:alfresco/forms/controls/MultiSelect#Result
-
The currently focused result item
Type:
- module:alfresco/forms/controls/MultiSelect#Result
- Source:
-
_itemsToUpdateFromStore :object[]
-
Collection of items which are "temporary" and need updating from the store NOTE: It is assumed these items are also in the _storeItems collection, so their properties can just be updated in-situ
Type:
- object[]
- Source:
-
_latestSearchRequestIndex :number
-
The index of the latest search request
Type:
- number
- Source:
-
_loadingMessageTimeoutMs :number
-
How long a query can run (ms) before a loading message is displayed
Type:
- number
- Source:
-
_newSearchTimeoutPointer :number
-
Timeout used to debounce new search requests
Type:
- number
- Source:
-
_resultListeners :object[]
-
Collection of listeners for the results dropdown to help track and remove them when no longer needed
Type:
- object[]
- Source:
-
_results :Result[]
-
The results
Type:
- Result[]
- Source:
-
_searchDebounceMs :number
-
The number of milliseconds to debounce search requests, i.e. the pause needed during typing for a search request to actually kick off
Type:
- number
- Source:
-
_showLoadingTimeoutPointer :number
-
A timeout to ensure the loading message does not display if the results come back super-quick
Type:
- number
- Source:
-
_suppressKeyUp :boolean
-
Sometimes we want to prevent key-up from performing a search, which we will know immediately before in the keypress handler. This property supports that behaviour.
Type:
- boolean
- Source:
-
cssRequirements :object[]
-
An array of the CSS files to use with this widget.
Type:
- object[]
- Default Value:
- [{cssFile:"./css/MultiSelect.css"}]
- Source:
-
i18nRequirements :object[]
-
An array of the i18n files to use with this widget.
Type:
- object[]
- Default Value:
- [{i18nFile: "./i18n/MultiSelect.properties"}]
- Source:
-
inferMissingProperties :boolean
-
Whether to infer missing properties on retrieved option objects.
NOTE: The "name", "label" and "value" properties are retrieved using the "query", "label" and "value" attribute names as configured in the store.
Priorities are:
- Missing name takes label if available, else value
- Missing label takes name if available, else value
- Missing value takes name if available, else label
Type:
- boolean
- Since:
- 1.0.42
- Default Value:
- false
- Source:
-
rootClass :string
-
The root class of this widget
Type:
- string
- Source:
-
templateString :String
-
The HTML template to use for the widget.
Type:
- String
- Source:
-
value :object[]
-
The current value of the control
Type:
- object[]
- Source:
-
valueDelimiter :string
-
An optional token that can be provided for splitting the supplied value. This should be configured when the value is provided as a string that needs to be converted into an array.
Type:
- string
- Since:
- 1.0.77
- Default Value:
- null
- Source:
-
width :string
-
The width of the control, specified as a CSS value (optional)
Type:
- string
- Source:
-
<inner> _nodes :object
-
Node pointers for dynamic elements created by this widget (and not in the template)
Type:
- object
- Source:
-
<inner> labelFormat :object
-
An object that defines the formats of the labels. See main module example for example. It should be a format string for each of the three label strings
Type:
- object
- Default Value:
- undefined
- Source:
- See:
-
- {module:alfresco/forms/controls/MultiSelect#Label}
Methods
-
_chooseFocusedItem() → {boolean}
-
Choose the focused item in the results dropdown
- Source:
Returns:
Returns true if item is chosen- Type
- boolean
-
_createDropdown()
-
Create this control's dropdown element, which must be at page level to ensure its stacking context permits proper display even within dialogs.
- Source:
-
_createHighlightedResultLabel(resultLabel) → {object}
-
Create a document fragment of a label, highlighted with the current search term
Parameters:
Name Type Description resultLabel
string The label - Source:
Returns:
A document fragment of the highlighted label- Type
- object
-
_debounceNewSearch(searchString)
-
Do not fire multiple searches needlessly. Debounce the search requests, i.e. wait until the user has paused typing to actually do the search.
Parameters:
Name Type Description searchString
string The search string to use - Source:
-
_emptyResults()
-
Empty the results dropdown
- Source:
-
_getCursorPositionWithinTextbox() → {number}
-
Get the cursor position within the search box NOTE: Uses code derived from http://javascript.nwbox.com/cursor_position
- Source:
Returns:
The cursor position (zero-indexed)- Type
- number
-
_getLabel(item) → {module:alfresco/forms/controls/MultiSelect#Label}
-
Overrides the inherited function to return a more complex label object to satisfy requirements of the drop-down.
Parameters:
Name Type Description item
item The item whose label to retrieve - Source:
Returns:
- Type
- module:alfresco/forms/controls/MultiSelect#Label
-
_gotoNextResult(reverseCommand)
-
Go to the next result in the dropdown, or the first one if none selected (ignores already-chosen items)
Parameters:
Name Type Description reverseCommand
boolean If true then go to previous item instead - Source:
-
_handleSearchFailure(err)
-
Handle failures that occur when calling the search service
Parameters:
Name Type Description err
object The error object - Source:
-
_handleSearchSuccess(responseItems)
-
Handle the (successful) response from the search service
Parameters:
Name Type Description responseItems
object The response items - Source:
-
_hideEmptyMessage()
-
Hide the empty message in the dropdown
- Source:
-
_hideErrorMessage()
-
Hide the error message in the dropdown
- Source:
-
_hideLoadingMessage()
-
Hide the loading message in the dropdown
- Source:
-
_hideResultsDropdown()
-
Hide the results dropdown
- Source:
-
_onBlur()
-
Handle blur events on the search box
- Source:
-
_onChoiceClick(choiceObject, evt)
-
Extends the inherited function to remove the focus from results.
Parameters:
Name Type Description choiceObject
object The choice (node) being clicked on evt
object Dojo-normalised event object - Source:
-
_onControlClick(evt)
-
Handle clicks on the control
Parameters:
Name Type Description evt
object Dojo-normalised event object - Source:
-
_onFocus()
-
Handle focus events on this control
- Source:
-
_onResultMousedown()
-
Handle mousedowns on the result items NOTE: We're using mousedown rather than click to evade problems with the searchBox blur event
- Source:
-
_onResultMouseover(evt)
-
Handle mouseovers on the result items
Parameters:
Name Type Description evt
object Dojo-normalised event object - Source:
-
_onSearchChange(newValue)
-
Handle changes to the search box value
Parameters:
Name Type Description newValue
string The new search value - Source:
-
_onSearchKeypress(evt)
-
Handle keypress events on the search box
Parameters:
Name Type Description evt
object Dojo-normalised event object - Source:
-
_onSearchKeyup(evt)
-
Handle keyup events on the search box
Parameters:
Name Type Description evt
object Dojo-normalised event object - Source:
-
_onSearchUpdate()
-
Handle updates to the search box, which may or may not result in the search value having changed
- Source:
-
_positionDropdown()
-
Position the dropdown appropriately
- Source:
-
_preventWidgetDropdownDisconnects()
-
Prevent the absolutely positioned dropdown from being disconnected from the main widget. Because the dropdown is positioned every time it's displayed, all we need to do is hide it when we detect a circumstance that could cause a disconnect.
- Source:
-
_removeChoice(choiceToRemove, evt)
-
Extends the inherited function to update the results dropdown and [hide it]{@link module:alfresco/forms/controls/MultiSelect#_hideResultsDropdown}.
Parameters:
Name Type Description choiceToRemove
object The choice object to remove evt
object Dojo-normalised event object - Source:
-
_resetControl()
-
Reset the control. Empties the search box, hides the dropdown and cancels any pending requests
- Source:
-
_resultsDropdownIsVisible() → {boolean}
-
Test whether the results dropdown is currently visible
- Source:
Returns:
The results dropdown's visibility- Type
- boolean
-
_selectChoice(choiceNodeOrOffset)
-
Select the specified choice
Parameters:
Name Type Description choiceNodeOrOffset
object | number The choice node to select or the adjustment offset from the currently selected one, which must be either 1 or -1. If none is selected, then the start position is to the right of the current choices. - Source:
-
_setupDisabling()
-
Consolidate the disabled-state changes into a single method, rather than peppering the code with lots of little snippets.
- Source:
-
_setupScrollHandling()
-
Setup listening for scrolls happening which can affect the position of this control and hence the dropdown
- Since:
- 1.0.33
- Source:
-
_showEmptyMessage()
-
Show the empty message in the dropdown
- Source:
-
_showErrorMessage(message)
-
Show the error message in the dropdown
Parameters:
Name Type Description message
string The error message to be shown - Source:
-
_showLoadingMessage()
-
Show the loading message in the dropdown
- Source:
-
_showOrSearch()
-
If we have current results then open the dropdown, otherwise perform a new search.
- Source:
-
_showResultsDropdown()
-
Show the results dropdown
- Source:
-
_startSearch(searchString)
-
Start a new search
Parameters:
Name Type Description searchString
string The string to search on - Source:
-
_unfocusResults()
-
Un-focus all results
- Source:
-
_updateItemsFromStore()
-
Update all of the items in _itemsToUpdateFromStore with info from the store
- Source:
-
_updateResultsDropdown()
-
Update the results list
- Source:
-
buildRendering()
-
Widget template has been turned into a DOM
- Source:
-
constructor()
-
Constructor
- Source:
-
get(propName)
-
Get the specified property
Parameters:
Name Type Description propName
string The name of the property to retrieve - Source:
-
getItemValue() → {object}
-
Overrides the inherited function to return the target item mapped in the store.
- Since:
- 1.0.54
- Source:
Returns:
The search box element.- Type
- object
-
getNewChoiceRelativePosition() → {object}
-
Overrides the inherited function indicate that choices should be placed before the search box.
- Since:
- 1.0.54
- Source:
Returns:
The search box element.- Type
- object
-
getNewChoiceTargetNode() → {object}
-
Overrides the inherited function to return the search box as the DOM element to add choices relative to.
- Since:
- 1.0.54
- Source:
Returns:
The [search box]module:alfresco/forms/controls/MultiSelect#searchBox element.- Type
- object
-
getStoreItem() → {object}
-
Overrides the inherited function to return the mapped item from the store.
- Since:
- 1.0.54
- Source:
Returns:
The [search box]{@link module:alfresco/forms/controls/MultiSelect#searchBox} element.- Type
- object
-
getValue() → {string[]}
-
Get the value of the control
- Source:
Returns:
The value(s) of the control- Type
- string[]
-
isDisabled() → {Boolean}
-
Whether the control is disabled
- Source:
Returns:
If disabled then true- Type
- Boolean
-
normaliseItem(item) → {object}
-
Normalise an individual item, to make the data suitable for use with this widget.
Parameters:
Name Type Description item
object The item to be normalised - Since:
- 1.0.42
- Source:
Returns:
The normalised item (returned for convenience)- Type
- object
-
postCreate()
-
Widget has been created, but possibly not sub-widgets
- Source:
-
set(propName, propValue)
-
Set the specified property
Parameters:
Name Type Description propName
string The name of the property to update propValue
* The new value - Source:
-
setDisabled(newValueParam)
-
Set whether the control is disabled
Parameters:
Name Type Description newValueParam
boolean True to disable, false to enable - Source:
-
setValue(newValue)
-
Set the value of the control
Parameters:
Name Type Description newValue
string | Array.<string> | object | Array.<object> The new value(s) - Source: