Code Snippets Support for JavaScript Text Boxes
Using Monaco Intellisense available via the Monaco Editor, the platform provides two mechanisms for using code snippets in Java Script text boxes, as follows:
- $s. - displays code snippets
- $m. - displays code snippets for entities and attributes.
The sections below describe how to use the two mechanisms.
Code Snippets
Writing $s. opens a drop-down list which offers the possibility to choose a snippet name or another. There might be one or more entries in the list which are not snippets but group names in which case typing a dot after them will open new drop-down menu.
The snippets can be organized in menus or drop-downs on multiple levels in structures like hierarchies.
A snippet name together with its selection path may look like:
$s.ebs.functions.callAction
Placing the cursor right at the end of the snippet path/name (full name) and pressing the TAB key, the system will replace the string with:
ebs.callAction( actionId, { id:ebs.getCurrentEntityId() }, function( e ) { function body; });
In the example provided above, “ebs.“ is inserted in front of the function to reduce further typing.
Code Snippets Placeholders
The code snippets might contain hint words, known as placeholders which can be easily selected and changed. The placeholders are highlighted with a background color.
In the example provided above, the ebs.callAction function snippet, “actionId” and “function body“, although not visible in the text above, might be placeholders.
Navigating placeholders
Upon snippet insertion, the cursor will be placed on the first placeholder (if any). If no placeholder is available, the cursor will go to the end of the snippet.
To navigate from one placeholder to another, press the TAB key or SHIFT+TAB.
Pressing TAB when the cursor is over the last placeholder will move the cursor at the end of the snippet.
Replacing placeholders
There might be placeholders without underlying text, visible due to a narrow gray line on that position.
When the cursor is over a placeholder, starting to type will remove the placeholder text.
The presence of one or more cursors indicate that those placeholders will be filled in simultaneously with the same text. Additionally, such group of placeholders might have identical texts beneath.
Make sure to replace the placeholders and click OK to save the source code changes.
Deactivating placeholders
When the cursor falls outside the snippet, the placeholders will be deactivated and any text which has not been replaced will remain in the snippet.
When the placeholders are deactivated:
- They are no longer highlighted with a background color
- Navigating from one placeholder to another is no longer possible using TAB and SHIFT+TAB.
- Typing when cursor is on top of the placeholders will not remove the placeholder text.
Series of placeholders
Some snippets may have for some fields’ series of placeholders in a row, like: left inner right
To eliminate the unwanted variants and keep the desired one, navigate placeholders using TAB or SHIFT+TAB and when on top of the placeholder that you want to eliminate, press the delete key.
Nested code snippets
Snippets might be nested, meaning that in a placeholder you can insert another snippet, without deactivating the placeholders of the first snippet.
Code snippets for entities and attributes
The $m mechanism has been introduced to enable FintechOS engineers to easily select entities and attributes names, transforming them in strings if necessary.
Writing $m. opens a drop-down list containing existing entities. Selecting an entity and typing a dot opens a new drop-down containing the attributes of that entity. Pressing TAB after the inserted entity or attribute transforms the expression into a string which contains only the name of the entity or attribute depending on the selection(s) made from drop-down(s).
If selecting the current entity from the drop-down, data extensions (if any will also be displayed) in the drop-down list.
- Pressing TAB after
$m.Account.Accountid
transforms the expression into "Accountid" - Pressing TAB after
$m.Account
transforms the expression into "Account"
.$m.Account.Accountid
transforms the expression into .Accountid