Show context menu
Event action – Abstract
Purpose: Opens a context menu defined specifically for this purpose at the current mouse cursor position in the client to enable selection.
The Show context menu event action opens a context menu at the current mouse cursor position in the client – starting from a possibly specially generated 'list' of choices.
The user's selection can be processed with one of the following modes:
Either the selection is processed synchronously server-side. Then the event handling is interrupted until the user's selection provides a return object for the subsequent event actions. If a parameterizable waiting time (>0 seconds) elapses without any selection, the context menu closes automatically.
Alternatively, the selection is processed asynchronously and exclusively on the client-side. Then a Client workflow defines event actions that the client executes as soon as a return object is selected, while the server continues event handling immediately after the context menu is opened.
In both cases, the user can close the context menu by pressing the Esc key or an interaction in the surrounding window (such as a mouse click outside the context menu) without making a selection.
When closing without any selection, 'no value' ($null) is passed as a return object to the event actions to be executed. Therefore, these are always executed after closing the context menu, so that the special case 'no selection' should be intercepted e.g. by an If then else or Execute with event action or in the Client workflow by a suitable 'Validating rule'.
Configuration
Parameter
|
|
The other parameters concern the behaviour of the opened context menu with regard to the selection of an entry by the user. Depending on the selected Mode, different configuration options are offered here: |
|
The default Mode is the option 'Receive Item', which opens the context menu synchronously.
|
|
Alternatively, the Mode can be changed to the 'Execute action on client' option, which opens the context menu asynchronously, so that event handling continues immediately without waiting for a selection in the open context menu. The only Item click action available when selected is the 'Client workflow' option. By selecting this option, a Client workflow can be defined that the event handler passes to the client at runtime for execution when the context menu is closed. The following applies to the context of the client workflow:
►NOTE◄ In conjunction with the Mode 'Execute action on client', the context menu remains open 'indefinitely' in principle. |
|
Definition of entries for the context menu
Basically, any list can be used to create a context menu via the value explorer for Root items. Lobster Data Platform / Orchestration offers various possibilities to generate lists via value resolvers or to extract them from existing data sources. The following examples pick out selected techniques from an extensive solution space.
Based on the default values for the Label expression (label), Children field (children), and Icon expression (icon) parameters, a static definition for a context menu in JSON format might look like this:
[ { "label" : "COMPASS" , "icon" : "fa://fal-compass" , "children" : [ { "label" : "North" , "icon" : "fa://fal-arrow-up" }, { "label" : "East" , "icon" : "fa://fal-arrow-right" }, { "label" : "South" , "icon" : "fa://fal-arrow-down" }, { "label" : "West" , "icon" : "fa://fal-arrow-left" } ] }, { "label" : "GPS" , "icon" : "fa://fal-satellite" } ] |
Using an JSON to object value resolver (see also the 'Examples' section below), a 'list' for the Root items parameter in a Show context menu event action can be created from the JSON structure shown on the left. Runtime example: The context menu opens when you click on a button to specify the destination of a tour more or less precisely.
|
To organize items in the same level of a context menu, a horizontal line can be created by adding an element to the list at the position in question, specifying the field type with the value hline.
►NOTE◄ The horizontal line is not selectable as a menu entry.An entry in the context menu appears disabled if the element in question has a field with the name disabled that is assigned the value true (as a Boolean value, not as text!).
►NOTE◄ A disabled entry with children fields shows the '>' symbol in the right margin, but does not expand the children field. So a disabled item may hide a complete branch of a menu tree.
Both possibilities are illustrated by the following adaptation for the above example:
[ { "label" : "COMPASS" , "icon" : "fa://fal-compass" , "children" : [ { "label" : "North" , "icon" : "fa://fal-arrow-up" }, { "label" : "South" , "icon" : "fa://fal-arrow-down" }, { "type" : "hline" }, { "label" : "East" , "icon" : "fa://fal-arrow-right" }, { "label" : "West" , "icon" : "fa://fal-arrow-left" } ] }, { "label" : "GPS" , "icon" : "fa://fal-satellite" , "disabled" : true } ] |
|
►NOTE◄ For the sake of simplicity, the introductory example omits two aspects in the menu definition that may be important in practice: The menu entry labels define static texts without reference to the Localization, so that the menu appears identical in all languages. In addition, the selectable list items do not provide a field that is used exclusively to identify the selected item. The user's selection would therefore have to be identified by the label or icon in the return object, or a combination of both features. Changes to these features then also generate changes in the triggered event handlings. The first of the following examples shows a more appropriate solution for both aspects.
Examples
Professionalization of the introduction example
First, the following will show how the configuration for the introductory example can be implemented in more detail and in a more 'professional' way, which on one hand ensures a language-dependent labeling of the menu items and on the other an independent identification of the selection options.
Configuration:
First, the static text for the definition of Root items is adjusted as shown below on the left. Then the entries shown on the right are created in the Localization.
[ { "key" : "COMPASS" , "icon" : "fa://fal-compass" , "children" : [ { "key" : "N" , "icon" : "fa://fal-arrow-up" }, { "key" : "E" , "icon" : "fa://fal-arrow-right" }, { "key" : "S" , "icon" : "fa://fal-arrow-down" }, { "key" : "W" , "icon" : "fa://fal-arrow-left" } ] }, { "key" : "GPS" , "icon" : "fa://fal-satellite" } ] Instead of labels, a unique field key is now provided, which at the same time ensures the unique identification and thus the starting point for a localization of the entries via the Localization (see right). |
|
The implementation of the context menu within an event handler or in a Client workflow can be implemented on this basis as shown below:
►NOTE◄
|
|
Build context menu from the result of a tuple search
Requirement:
Within an input form, certain user accounts are to be offered for selection in a context menu in order to trigger the creation of an e-mail message to their address via the mailto protocol.
Detailed requirements:
|
Runtime example:
|
Configuration:
The desired flow can be handled completely as a Client workflow in the following steps, e.g. in a behaviour for the button:
|
|
Relevant configurations for each step of the client workflow are discussed below:
Search action |
|
|
|
The negation can only be displayed here via a Case projection, which can be configured with a few clicks. For the context menu, it is important that the values assigned as Literal projection (true or false) are actually of the Boolean data type and not just text values with the same wording. |
►NOTE◄ Depending on the specific requirements, 'conditions' for the Search (Event action) may have to be specified, since otherwise all 'readable' user accounts will appear as contact persons. Details on this are omitted for lack of relevance with regard to the context menu.
Open context menu |
|
The Search (Event action) stores all returned result rows as a list in the users variable, which can thus be used directly in the value explorer for the Root items for the context menu to be opened:
|
|
Notify selected contact person... |
|
After closing the context menu, a check should urgently be made whether a user has been selected or not. For this purpose, an If then else event action can be configured as shown to the right:
Runtime example:
►NOTE◄ The rigid structure used here for the e-mail address is of course only legitimate if all Users listed in the context menu can be reached via the same domain and that the mail address there always corresponds to their user name for Lobster Data Platform / Orchestration. In a real situation, a more elaborate logic for determining the e-mail address would certainly be appropriate, which could, for example, include further data from the user account. |
|