Adding @mention for fields in Progressive Web Applications
To support the @mention component for Progressive views, the following properties are added in Developer Studio:
Property name | Property type | Property values | Description |
---|---|---|---|
Enable Menu Hotkeys | Boolean |
| Specifies if the menu hotkeys are to be enabled. To define menu hotkeys, you must set the value of this property to True. |
Menu Hotkeys | String | A string | Use this property to define hotkey definitions. By default, the text "No Hotkey Defined" is displayed as the value for this property. |
To configure the @mention component
- On the Progressive view of a form, double-click a Character field.
- On the Properties panel, under the Display property group, for the Enable Menu Hotkeys property, select the True value.
- In the Value column for the Menu Hotkeys property, click the ellipsis button.
The Menu Hotkeys dialog box is displayed. Click Add, and then perform the following steps:
Column
Step
Hotkey
Click the first row in this column, and then select a character from the list.
Menu Name
Click the first row in this column, and then click the ellipsis button to select a menu from the Menu Selector dialog box.
Active Link
Click the first row in this column, and then click the ellipsis button to select an active link from the Active Link Selector dialog box.
The active link that you attach to a hotkey must be an existing one and associated with the current form.
Labels
Click the first row in this column, and then in the box, type in labels that are separated by a semicolon.
Auto Complete Key Stroke #
Enter an integer value.
- Click OK.
Parameters for hotkey definition
The following parameters can be a part of any hotkey definition:
Parameter | Description |
---|---|
Hotkey | When you press this character key, the @mention component is executed based on the other parameters that you've provided in the hotkey definition. This parameter is the mandatory part of any @mention definition. |
Menu Name | This is a name of the menu that is used to populate the popup. This parameter is the mandatory part of any @mention definition. |
Active Link | This is a name of the active link that gets executed when you select an item from the popup. This parameter is an optional part of any @mention definition. |
Labels | This is a set of labels that are defined for a menu. This parameter is an optional part of any @mention definition. |
Auto Complete Key Stroke # | You can enter an integer value value for this parameter. For example, if you enter the value 3, a drop-down list appears after you type three characters in the menu. If you enter the value zero (0), the drop-down list appears as soon as type a hotkey character key. |
There are scenarios when you want the users of your application to have the option of selecting the type of content that they see in an autosuggest list when using @mention. You can create such a search field by using the CHANGE_HOTKEY_MENU command.
To enable users to select the type of content displayed in @mention
In the following example scenario, as an application developer, you add the CHANGE_HOTKEY_MENU command to enable the application users to decide the type of content in the @mention list. However, note that real-world implementations can vary considerably depending on your business needs.
Before you begin
Make sure that you fulfil the following conditions before you perform the steps for creating fields where users can switch between @mention content.
- In Developer Studio, you must have a form that contains usernames and a form that contains asset names.
- You must have predefined search menus of type Search.
Process for creating fields where users can switch between @mention content
The following diagram shows a high-level overview of the steps required to create fields where users can switch between different types of @mention content:
Create two buttons and a character field. The character field consists of a default @mention menu. The buttons are assigned active links and menus which should replace the default @mention menu when the buttons are clicked by application users.
The following animation explains a high-level concept of the use case:
To create the field and buttons
In this procedure, we create a character field with a default menu, two buttons that contain an active link that uses the CHANGE_HOTKEY_MENU.
- In Developer Studio, create a New Regular Form.
Create a Progressive View.
- Add two buttons to the view.
- Name the buttons as Assets Only and Users Only.
- (Optional) Add a new section panel.
To define the hotkey for the character field
- Add a character field and add a hotkey associated with a search menu to it.
- From the Palette, drag Character into the view or the section panel.
Developer Studio assigns it a default name such as Character Field_c. - Select the character field and rename it to Character Field.
- In the Properties tab, click Display > Enable Menu Hotkey and select True.
This enabled you to set a hotkey for the character field. - Below the Enable Menu Hotkey property, click the ellipsis (
The Menu Hotkeys dialog opens. ) button next to Menu Hotkeys. Click Add.
Developer Studio adds @ in the Hotkey column.- In the Menu Name column, click the ellipsis (
The Menu Selector dialog opens. ) button. - Find the search menu that lists usernames and assets you want to associate with the hotkey and click OK.
- In the Auto Complete Key Stroke # column, add 3.
The autosuggest is activated when application user types at least three characters. In the Properties tab, set a value in pixels for the Hotkey Menu Max Height property.
This is the maximum height of the @mention list when it displays a large number of results. The default value of the Hotkey Menu Max Height property is 200.
- From the Palette, drag Character into the view or the section panel.
- Save the form with a name.
- In this example name the form as ChangeHotkeyMenu.
To create a search menu that contains usernames
- Create a new search menu.
- Select AR System Navigator > aRServerName > All Objects > Menus > New Search Menu.
The hotkey supports only search menus. - Click the ellipsis (
The Form Selector dialog opens. ) button next to Form Name. - Find and add the user form that contains all usernames, and click OK.
- Save the search menu.
In this example, name the menu as ChangeHotkeyMenuM1.
To create a search menu that contains asset names
- Create another search menu and name it as ChangeHotkeyMenuM2.
This menu must list all asset names. - Click the ellipsis (
The Form Selector dialog opens. ) button next to Form Name. - Find and add the form that contains all asset names, and click OK.
- In the Label Fields section, click Add.
The Field Selector dialog opens. - Select Asset Name, and click OK.
- Save the search menu.
In this example, name the menu as ChangeHotkeyMenuM2.
To create an active link for the Users Only button
- Create an active link for the Users Only button named ChangehotkeymenuAL1.
- Select New > Active Link.
Add the following settings to the active link:
Setting
Value, selection, or function
Additional details
Associated Forms > Add
ChangeHotkeyMenu
Execution Options > Button/Menu Field
Users
This is the button that triggers the active link.
Run If Qualification
1=1
This triggers the run process in the If Actions without exception.
If Actions > Add action > Run Process
CHANGE_HOTKEY_MENU fieldID @ changehotkeymenuM1 $NULL$ $NULL$ 3
Make sure that there is a single space between each attribute.
fieldID is the ID of Character Field.
changehotkeymenuM1 is not dynamic and must always be hardcoded (static). This active link runs when you type three characters, that is, when you type @ in the Character Field and it fetches information from the ChangehotkeymenuM1 search menu.
To create an active link for the Assets Only button
- Create another active link for the Assets Only button named ChangehotkeymenuAL2.
- Select New > Active Link.
Add the following settings to the active link:
Setting
Value, selection, or function
Additional details
Associated Forms > Add
ChangeHotkeyMenu
Execution Options > Button/Menu Field
Assets
This is the button that triggers the active link fetches and uses it to replace the default menu of the character field.
Run If Qualification
1=1
This triggers the run process in the If Actions without exception.
If Actions > Add action > Run Process
CHANGE_HOTKEY_MENU fieldID @ changehotkeymenuM2 activeLink1 labelsToShow 3
Make sure that there is a single space between each attribute.
fieldID is the ID of Character Field.
changehotkeymenuM2 is not dynamic and must always be hardcoded (static) with the menu name. This active link runs when you type three characters, that is, when you type @ in the Character Field and it fetches information from the ChangehotkeymenuM2 search menu.
- Save the changes.
Validating the character field in PWA
View the form in the progressive web application screen to check whether it works as intended.
- In a browser, log in to PWA.
For example, <serverName>:8080/arsys/pwa/#/login - Change the URL to include the Progressive View form that you created in Developer Studio.
<serverName>:8080/arsys/pwa/#/forms/<serverName>/<formName>/<progressiveViewName> - The PWA screen displays the character field and the buttons.
- In Character Field, type @ followed by three characters.
The field displays users and assets. - Click Users Only and type @ followed by three characters.
The field displays usernames. - Click Assets Only and type @ followed by three characters.
The field displays assets names.
Where to go from here
Learn more about the syntax and additional options within the process command in the Process-commands topic.