Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 98 additions & 1 deletion docs/creating-manifest/conditions-and-iterations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# Control Flows: Conditions and Iterations

**Comparison** and **Logical** operators are used in *conditional* statements and serve to test for `ture` or `false`.

## Comparison Operators

The Comparison operators are used in logical statements to determine equality or difference between variables or values.

Let's assume that `x = 5`. The table below explains the comparison operators:

| Operator | Description | Comparing | Returns |
|--------------------|-------------------------------------|-----------|----------|
| == | equal to | x == 8 | false |
| == | equal to | x == 5 | true |
| == | equal to | x == "5" | true |
| | | | |
| === | equal value and equal type | x === 5 | true |
| === | equal value and equal type | x === "5" | false |
| | | | |
| != | not equal | x != 8 | true |
| | | | |
| !== | not equal value or not equal type | x !== 5 | false |
| !== | not equal value or not equal type | x !== "5" | true |
| !== | not equal value or not equal type | x !== 8 | true |
| | | | |
| > | grater than | x > 8 | false |
| < | less than | x < 8 | true |
| >= | grater than or equal to | x >= 8 | false |
| <= | less than or equal to | x <= 8 | true |

## Logical Operators

The logical operators are used to determine the logic between variables or values. Let's take that `x = 6` and `y = 3`. The table below explains the logical operators:

| Operator | Description | Example |
|--------------------|-------------------------------------|------------------------------|
| && | and | (x < 10 && y > 1) is true |
| == | or | (x == 5 || y == 5) is false |
| == | not | !(x == y) is true |





## Conditions

The main conditional statement is <b>*if*</b>. Within this parameter, all the available <a href="../placeholders/" target="_blank">placeholders</a> and their objective JavaScript mappings can be used.
Expand Down Expand Up @@ -204,7 +246,7 @@ onInstall:
```
@@!

### **Else**
### Else

In case the conditional statement should be complemented by the opposite comparison and respective action the ***else*** conditional operator can be accommodated.

Expand Down Expand Up @@ -431,6 +473,61 @@ onInstall:
```
@@!

### Single line *if* statement

Another ***if-else*** combination can be represented as a single ***if*** statement when multiple conditions are required to be checked and the statements nesting is not mandatory.
It is applicable if any condition or all of the conditions in the statement may lead to the same outcome.
For example:

@@@
```yaml
type: install
name: '[CS:Conditions] - action single line "if"'

globals:
a: 1
b: 2

onInstall:
- log: "-- single line if test --"
- if ((globals.b == 2) && (globals.a == 1) && (globals.a == 1)):
assert: true

- log: "-- another single line if test --"
- if (globals.a == 2 || globals.a == 3 || globals.a == 1):
assert: true
```
```json
{
"type": "install",
"name": "[CS:Conditions] - action single line \"if\"",
"globals": {
"a": 1,
"b": 2
},
"onInstall": [
{
"log": "-- single line if test --"
},
{
"if ((globals.b == 2) && (globals.a == 1) && (globals.a == 1))": {
"assert": true
}
},
{
"log": "-- another single line if test --"
},
{
"if (globals.a == 2 || globals.a == 3 || globals.a == 1)": {
"assert": true
}
}
]
}
```
@@!


## Iterations

### ForEach
Expand Down
79 changes: 52 additions & 27 deletions docs/creating-manifest/visual-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ where:
* `text` - [multiline](#text) text field
* `list` - drop-down menu with [textboxes](#list)
* `checkbox` - [single checkbox](#checkbox) field
<!-- * `checkboxlist` - [checkbox](#checkboxlist) grouping -->
* `checkboxlist` - [checkbox](#checkboxlist) grouping
* `radiolist` - [radio field](#radiolist) grouping
* `radio-fieldset` - alias to `radiolist`
* `dockertags` - drop-down menu with a list of [docker tags](#dockertags)
Expand Down Expand Up @@ -554,47 +554,72 @@ where:
- `hideLabel` *[optional][boolean]* - shows/hides field label. Default value is *'false'*
- `hidden` *[optional]*[boolean] - shows/hides field with its label. Default value is *'false'*.

<!--
### checkboxlist
Checkbox grouping.

![text](/img/checkboxlist.jpg)
![text](/img/checkboxlist.jpg)

@@@
```yaml
fields:
- type: checkboxlist
caption: Checkbox List
values:
value1: hello
value2: world
hideLabel: false
hidden: false
- type: checkboxlist
caption: Options
name: options
columns: 2
values:
- name: option1
caption: Option 1
value: false

- name: option2
caption: Option 2
value: true

- name: option3
caption: Option 3
value: true
```
``` json
{
"fields": [
{
"type": "checkboxlist",
"caption": "Checkbox List",
"values": {
"value1": "hello",
"value2": "world"
[
{
"type": "checkboxlist",
"caption": "Options",
"name": "options",
"columns": 2,
"values": [
{
"name": "option1",
"caption": "Option 1",
"value": false
},
"hideLabel": false,
"hidden": false
}
]
}
{
"name": "option2",
"caption": "Option 2",
"value": true
},
{
"name": "option3",
"caption": "Option 3",
"value": true
}
]
}
]
```
@@!

where:
This example returns values as follows:

*{ "options": "option2,option3", "option1": false, "option2": true, "option3": true }*

Field parameters:

- `caption` *[optional]* - field label
- `values` - checkboxes (*"key"*:*"value"*)
- `hideLabel` *[optional] [boolean]* - shows/hides field label. Default value is *'false'*
- `hidden` *[optional]*[boolean] - shows/hides field with its label. Default value is *'false'*.
-->
- `hidden` *[optional]*[boolean] - shows/hides field with its label. Default value is *'false'*
- `delimiter` *[optional][string]* - a delimiter character to separate list data items. The default value is a comma ','
- `columns` *[optional][Number]* - specifies the number of columns to be created when displaying grouped checkboxlist controls using automatic layout. The default value is 1.


### radiolist
Radio elements grouping.
Expand Down
Binary file modified theme/readthedocs/img/checkboxlist.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.