# Statements editor

For components **Statements** and **Layer statements** a specialized editor is available. It allows statements to be defined using the JSON format.

## Editor location

The statements editor is available in the **Basic properties** components **Statements** and **Layer statements**.

<div data-with-frame="true"><img src="https://content.gitbook.com/content/2CssJT0zIo4SJQLbSZ6l/blobs/csYCRrr14KxrfbFOmt5n/7s_files/image2020-6-9_10-43-46.png" alt=""></div>

<p align="center"><em><strong>Illustration 1.</strong> Location where the statements editor is embedded</em></p>

The editor opens after clicking **Add statement**.

## Editor presentation

Opening the statements editor causes a drawer to slide out, presenting an area for entering text in JSON format. For a newly created component, it contains only curly braces with no content. Line numbers are visible on the left side of the editor.

The statements editor can be displayed in read-only mode and in edit mode. Read-only mode allows only viewing saved values.

<div data-with-frame="true"><img src="https://content.gitbook.com/content/2CssJT0zIo4SJQLbSZ6l/blobs/8EGwf4lk03qdwg2blDgZ/7s_files/image2020-6-9_10-54-51.png" alt="Figure 2. Appearance of the statements editor for a newly created component"></div>

The editor highlights both semantic and syntax errors in real time. When hovering the mouse cursor over the red underline indicating an error, a tooltip is displayed showing its content.

<div data-with-frame="true"><img src="https://content.gitbook.com/content/2CssJT0zIo4SJQLbSZ6l/blobs/fByJEMZxEU3zLD6JetT8/7s_files/image2020-6-9_11-3-2.png" alt="Figure 3. Example information about required fields"></div>

## Editor operation

The statements editor supports syntax hints. After pressing the key combination **Ctrl + Space** a hint is displayed containing fields that can be entered depending on the current cursor position in the editor. Selecting one of them and pressing **Enter** inserts that hint into the editor.

<div data-with-frame="true"><img src="https://content.gitbook.com/content/2CssJT0zIo4SJQLbSZ6l/blobs/m8NqoeCfjlMxyCn9MDq7/7s_files/image2020-6-9_11-21-14.png" alt="Figure 4. Hints displayed after pressing Ctrl + Space"></div>

The editor can be closed in two ways. The first is the **X** symbol in the upper-right corner (visible in Figure 2). The second way is to click outside the editor area.

{% hint style="info" %}
If, when closing the editor, the entered data is semantically and syntactically correct, it is saved. If it contains any error, the changes are discarded. In both cases, the drawer closes.
{% endhint %}

## Available fields

The statements editor accepts the fields listed below. Their meaning will be explained in the next paragraph. Required fields are additionally marked:

{% code title="Example JSON structure" expandable="true" %}

```json
{
  "items": [
    {
      "controls": [
        {
          "mid": "text",                 // required
          "titleKey": "text",           // required
          "type": "CHECKBOX|RADIO",      // possible values CHECKBOX or RADIO, required
          "visibleCondition": "text",
          "styleName": "text",
          "requiredCondition": "text",
          "notSelectedErrorTextKey": "text",
          "requiredNotAcceptedErrorTextKey": "text",
          "mastercheckbox": "text"
        }
        // ...
      ],
      "actionBindings": {
        "bindings": [
          {
            "event": "EDIT"             // possible value EDIT, required
          }
          // ...
        ]
      },
      "mid": "text",                   // required
      "textContent": "text",
      "textContentUnexpanded": "text",
      "visibleCondition": "text",
      "expandableCondition": "text",
      "expandedCondition": "text",
      "descriptionKey": "text",
      "nativePopupTitleKey": "text",
      "styleName": "text"
    }
    // ...
  ]
}
```

{% endcode %}

### Field meaning

| Property                  | Description                                                                                                                                                                                                                                                                                        |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **items**                 | List of defined statements to display.                                                                                                                                                                                                                                                             |
| **textContent**           | Artifact with the statement content displayed below the title specified in **titleKey**. If the artifact is specified, but the key **titleKey** and the control defined in **controls**are not provided, the textContent content will not contain the control.                                     |
| **textContentUnexpanded** | Artifact with the statement content displayed when the statement is collapsed.                                                                                                                                                                                                                     |
| **mid**                   | Business identifier of the given statement.                                                                                                                                                                                                                                                        |
| **visibleCondition**      | Conditions under which the given statement is to be displayed. If the condition is empty or invalid, the value "true" will be evaluated.                                                                                                                                                           |
| **styleName**             | Style name.                                                                                                                                                                                                                                                                                        |
| **expandableCondition**   | Condition for which text for collapsing/expanding the statement content should be displayed next to the statement title. If the condition is empty or invalid, the value "false" will be evaluated. Note: if **titleKey** is undefined, the text will not appear.                                  |
| **expandedCondition**     | If **expandableCondition** is set to "true", the property **expandedCondition** determines whether and when the statement content should be expanded by default. If the condition is empty or invalid, the value "true" will be evaluated (content expanded).                                      |
| **titleKey**              | Title key of a single statement defined in the **Translations**tab. Variables are resolved in keys.                                                                                                                                                                                                |
| **nativePopupTitleKey**   | Title key of the native popup that appears when clicking "More" → this text can be overridden by i18n.statements.item.native.more in the **Translations**tab. The popup is displayed only in the native application. If **nativePopupTitleKey** is not defined, the value of the key **titleKey**. |
| **event**                 | Event to add if an application action related to the given statement item has been defined.                                                                                                                                                                                                        |
| **controls**              | List of defined controls for the given statement. Explanation of the object fields **controls** is provided below.                                                                                                                                                                                 |

### **Defining the control list (controls)**

| Property                            | Description                                                                                                                                       |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| **mid**                             | Business identifier of the control (required field).                                                                                              |
| **titleKey**                        | Key of the title displayed next to/above the control.                                                                                             |
| **visibleCondition**                | Conditions under which the given control is to be displayed. If the condition is empty or invalid, the value "true" will be evaluated.            |
| **requiredCondition**               | Condition for which the control should be required. If the condition is empty or invalid, the value "true" will be evaluated.                     |
| **type**                            | Control type: **RADIO** - statement with two radio buttons YES/NO (other types such as CHECKBOX may also occur according to the JSON definition). |
| **notSelectedErrorTextKey**         | Translation key overriding the text "You have not made a selection".                                                                              |
| **requiredNotAcceptedErrorTextKey** | Translation key overriding the text "Consent to the selected statement is required".                                                              |
| **styleName**                       | Style name.                                                                                                                                       |
| **mastercheckbox**                  | Master checkbox ID.                                                                                                                               |
