Conditions class
📖 Description
The Conditions
class represents a collection of conditions of a form definition in the builder. Each condition in the collection is a Condition
instance.
🗃️ Fields
🏷️ all
Retrieves all the conditions that are in the collection.
Type
🏷️ branch
Retrieves the parent branch.
Type
🏷️ count
Retrieves the number of conditions in the collection.
Type
number
🏷️ firstItem
Retrieves the first condition in the collection.
Type
Condition
| undefined
🏷️ lastItem
Retrieves the last condition in the collection.
Type
Condition
| undefined
▶️ Methods
🔧 append
Appends a new condition to the end of the collection.
Signature
append(): Condition
Return value
Returns a reference to the new Condition
instance.
🔧 each
Iterates through all conditions in the collection.
Signature
each(fn: (condition: Condition) => boolean | void): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (condition: Condition ) => boolean | void | No | Function that is called for each condition in the collection. If you want to stop the iteration, you can return true from this function to do so. |
Return value
Returns true
if the iteration was stopped (break).
🔧 insert
Inserts a new condition at the top of the collection.
Signature
insert(): Condition
Return value
Returns a reference to the new Condition
instance.
🔧 insertAfter
Inserts a new condition after the supplied condition.
Signature
insertAfter(condition: Condition): Condition
Parameters
Name | Type | Optional | Description |
---|---|---|---|
condition | Condition | No | Specifies the condition after which the new condition is inserted. |
Return value
Returns a reference to the new Condition
instance.
🔧 insertBefore
Inserts a new condition before the supplied condition.
Signature
insertBefore(condition: Condition): Condition
Parameters
Name | Type | Optional | Description |
---|---|---|---|
condition | Condition | No | Specifies the condition for which the new condition is inserted. |
Return value
Returns a reference to the new Condition
instance.
🔧 reverseEach
Iterates through all conditions in the collection in reverse direction (starting with the last condition).
Signature
reverseEach(fn: (condition: Condition) => boolean | void): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (condition: Condition ) => boolean | void | No | Function that is called for each condition in the collection. If you want to stop the iteration, you can return true from this function to do so. |
Return value
Returns true
if the iteration was stopped (break).
🔧 sort
Sorts the conditions using the supplied compare function.
Signature
sort(fn: (a: Condition, b: Condition) => number): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (a: Condition , b: Condition ) => boolean | No | Specifies the compare function. The compare function should return a number according to the following rules: - a is less than b return -1;- a is greater than b return 1;- a is equal to b return 0. |
Return value
Returns true
if the sort invoked a condition position change.