The requirement is to have a new component to support auto-complete in multi entry fields. For example, autocomplete on airline names on the airlines search fields that support multiple airline codes.

The goal of this new widget is to accept several separated user entries, each time proposing the user with an auto-completion list when typing.

Here is the high level flow:

Focus is given to the widget.

User starts typing.

Auto-completion list is proposed.

Arrow Key for selecting the item.

The action to do the association is triggered when the TA press Enter Key.

Esc key cancel the edit mode and return back to the previous state.

An item is selected.

The item is transformed into a "graphical object" represented by a background color, the label, and a close icon.

The focus is given to the widget still, just on the right of the first object. User can continue typing and iterate again on the same steps.

The newly proposed list should not include the items that have been already selected.

Additionally, an object can be edited and deleted via the mouse and keyboard.

If User type a string that does not match any element in the list, error bubble is display at validation time (Enter Key).

The list does not include item(s) that have already been selected (option in the widget)

If the name is longer than the button size (Property of the Widget?) the name is displayed with ‘…’

Entry

Entries are done according to the global flow described above.

In some cases (free-text configuration), unknown inputs are typed in by the user (no item was selected from the auto completion list), in which case, a separator character marks the end of the entry (comma by default, but should be configurable).

When many items has been entered, and there is no available space left, the widget then expands vertically and the items wrap on the following lines. The entered text should match all word boundaries of the suggestion list.( but should be configurable).

Pax/Segment selection

We want to use the widget to select passengers or segments.
Passengers/Segments can be referred to by their name: ie 'John Doe' or 'AA1899', or their short name ie 'P1' or 'S1'.
Passengers or Segments should be selectable by autocompletion with either the full name or the short name (P1, S1). Moreover, we should be able to select multiple elements using numeric ranges as it is done with the cryptic commands:
"P1-3" selects passengers 1, 2 and 3 "S2,5,6" selects segments 2, 5 and 6

Wrapping

The width of the element representing a passenger or segment should expand so that the name is fully displayed. If There are too many elements to display on a single line, the widget should scale vertically and add a second line. If a name is too long to be displayed on a single line, an ellipsis should be displayed.

Auto-complete vs drop-down

The widget should be usable with large amounts of data through auto-completion lists, as well as with small amounts of data through simple drop-downs.
If the widget is configured to work with a drop-down of say, airlines, then an Expand button is displayed on the right side of the widget to give the whole list of items. Selecting from this list add a new object in the field.

Edit

Edition relies on the fact that "graphical objects" can be selected.

After a few entries have been typed, the user can go back and edit any of them in the following way.

"Graphical objects" have a close icon on the right side, clicking on it removes the entry.
"Graphical objects" can be clicked on once to be selected, and at the second click become editable (focus is given into the individual auto-complete field). At this stage, the text in the field can be erased and typed again just like with any singular auto-complete.

The edition can also be done via the keyboard:

Backspace selects the previous object.

Backspace while selected deletes the object.

Left/right arrow keys are used to select the previous/next objects.

Enter key goes to edit mode on the currently selected object.

Error Handling

The widget's field can be displayed in error state if there is a validation error, as seen below:

The normal AriaTemplates validation mechanism should apply to the widget: developers should be able to specify custom validation such as the maximum/minimum number of items, detection for duplicates, etc ...

On top of this, one type of validation at object level needs to be supported: when the widget is configured not to accept free-text, then the user may still type something that is not proposed by the completion list, ending by comma, however, in this case the invalid entry is marked by an error tip (located just above the entry), as shown below:

The normal AriaTemplates validation mechanism should apply to the widget: developers should be able to specify custom validation such as the maximum/minimum number of items, detection for duplicates, etc ...

We should be able to validate user input (number of items, etc) at the time the user hits enter to trigger the form submission. Then we should be able to display an error tooltip with a custom message if validation fails.

Technical Solution

Multi AutoComplete Part

Create a new widget called MultiAutoComplete which has a similar behaviour like autocomplete, in addition it has option to add multiple values with range supported.

Widget API

{@aria:MultiAutoComplete {

//.....
maxOptions : '' //Maximum no of options that can be selected with autocomplete.

The value returned by the autocomplete on choosing the option from suggestions are pushed to the value array.

The Selected options will be filtered from next autocomplete suggestions.

on clicking the close button on the selected value removes it from value array.

Multi AutoComplete Edit

Edit Mode is Handled by MultiAutoCompleteController when the user double click on selected value.

Only one value can be edited at a time.

_EditInputString method will check the edited value and Auto-Completion list is proposed, if the edited text does not match any element in the list and if free text is not allowed CheckError method will show error bubble on validation.

Clicking on the close removes it from value Array.

Multi Autocomplete Controller

The Multi Autocomplete Controller module handle the resource handlers, rendering of the suggestion template depending on the user interaction. Multi Autocomplete Controller handles the content and functionality similar to the AutocompleteController and MultiselectController and shares the similar behaviour. The expando button behaviour is handled by controller such that on click of button all suggestions will be shown along with checkboxes with 'select all', 'deselect all', 'close' links. Already selected values will be checked.

Handling of Ellipsis
Multiautpcomplete handler also handles ellipsis if the width of the selected value is wider than autocomplete width through

ellipseAutocompleteText

methodKey Board and Mouse Interaction

Clicking on the selected value highlights the selected option.

Clicking out side the MultiAutocomplete removes the highlight and closes the suggestion template

Side Arrow keys can be used to navigate through the selected value.

Double click on highlighted value goes to edit mode if freetext is enabled.

DEL and Backspace key press on highlighted value removes the value.

Click on expand button gives all the suggestions.

ESC key press removes the highlight from the selected value and put focus back to the input field of Autocomplete, if its in edit mode it should be changed to Read Mode.

MultiAutocompleteHandler
Source for MultiAutocomplete is handled by MultiAutocompleteHandler which extends the LCResourcesHandler. This handler should implement the IMultiResourceHandler Interface.

It also handles selecting the range of values. The range of value is handled by _getRangeSuggestions method which accepts the character only in the format P1-4 or P1,2,4 parses them to show the suggestions list having the range selected.

/**
* Call the callback with an array of suggestions in its arguments. Suggestions that are exact match are
* marked with parameter exactMatch set to true and filters the suggestions which are already exists in value array.
* @param {Object} entryObject having the text entry, value array and callback
*/
getSuggestions : function (entryObject) {