Skip to main content

Branch class

📖 Description

The Branch class represents a branch of the form definition in the builder.

🗃️ Fields


🏷️ conditions

Retrieves the collection of conditions.

Type

Conditions


🏷️ culling

Specifies the culling mode of the branch. This culling mode defines when the branch is taken. It can be one of the following values:

  • first: Branch is taken when one or more of the conditions match;
  • each: Branch is taken for each condition that matches (this allows a single branch to be taken multiple times);
  • all: Branch is taken when all of the conditions match;
  • none: Branch is taken when none of the conditions match.

Type

"first" | "each" | "all" | "none"

info

When a branch doesn't contain any conditions it will only be taken when the culling mode is first or all.


🏷️ epilogue

Specifies the epilogue (closing message) for the branch when the terminator mode is set to epilogue.

Type

IEpilogue | undefined


🏷️ id

Retrieves the identifier of the branch.

Type

string


🏷️ index

Retrieves the zero-based index of the branch in the Branches collection.

Type

number


🏷️ isFirst

Retrieves if the branch is the first branch in the Branches collection.

Type

boolean


🏷️ isLast

Retrieves if the branch is the last branch in the Branches collection.

Type

boolean


🏷️ isMoving

Retrieves if the branch is being moved (dragged) in the builder.

Type

boolean


🏷️ isRendered

Retrieves if the branch is rendered by the builder.

Type

boolean


🏷️ jump

Specifies the section to jump to when the branch ends.

tip

The terminator mode is automatically updated to jump when a section is set. When undefined is supplied, the terminator mode is automatically set to continuous when it was previously set to jump.

Type

Section | undefined


🏷️ name

Sets or retrieves the name of the branch.

Type

string


🏷️ parent

Retrieves a reference to parent Branches collection.

Type

Branches | undefined


🏷️ predecessor

Retrieves a reference to the predecessor Branch (if any).

Type

Branch | undefined


🏷️ section

Retrieves the parent section.

Type

Section | undefined


🏷️ sections

Retrieves the collection of child sections.

Type

Sections


🏷️ successor

Retrieves a reference to the successor Branch (if any).

Type

Branch | undefined


🏷️ terminator

Specifies the termination mode of the branch. This termination mode defines what happens when the branch ends. It can be one of the following values:

  • continuous: When the branch ends, the form continues with the next subsequent branch or section;
  • jump: When the branch ends a jump is made to another section defined by jump;
  • return: When the branch ends, the return to the parent form (only available for subforms);
  • abort: When the branch ends, the whole form ends;
  • epilogue: When the branch ends the form ends with a specific epilogue (form closing message).

Type

"continuous"| "jump" | "return" | "abort" | "epilogue"

▶️ Methods


🔧 delete

Deletes a branch from the Branches collection.

Signature

delete(): this

Return value

Returns a reference to the deleted Branch.


🔧 duplicate

Duplicates the branch.

Signature

duplicate(dest?: Branch): Branch

Parameters

NameTypeOptionalDescription
destBranchYesSpecifies the destination branch that is used to duplicate to. All current content of that branch is removed and replaced by the branch content that is duplicated. If omitted a new branch is added.

Return value

Returns a reference to the duplicated Branch.


🔧 insertAfter

Inserts a new branch after this branch.

Signature

insertAfter(): Branch

Return value

Returns a reference to the new Branch.


🔧 insertBefore

Inserts a new branch before this branch.

Signature

insertBefore(): Branch

Return value

Returns a reference to the new Branch.


🔧 load

Loads a nested branch (subform).

info

You can only load nested branches (subforms) to branches that have a parent section of type nest.

Signature

load(
definition: IDefinition,
reference?: string,
version?: string,
alias?: string,
readonly?: boolean
): boolean

Parameters

NameTypeOptionalDescription
definitionIDefinitionNoSpecifies the definition to load as subform.
referencestringYesSpecifies an optional reference to store.
versionstringYesSpecifies an optional version identifier.
aliasstringYesSpecifies an optional alias for the subform.
readonlybooleanYesSpecifies if the subform is read-only.

Return value

Returns true if the subform was loaded succesfully.

tip

See the Subforms guide for more information.


🔧 moveToIndex

Moves the branch to the specified index.

Signature

moveToIndex(index: number): boolean

Parameters

NameTypeOptionalDescription
indexnumberNoSpecifies the new index position for the branch where the first branch is 0.

Return value

Returns true if the move succeeded.


🔧 moveUpOrDown

Moves the branch up or down.

Signature

moveUpOrDown(up: boolean): boolean

Parameters

NameTypeOptionalDescription
upbooleanNoSpecifies if the move direction is up (true) or down (false).

Return value

Returns true if the move succeeded.


🔧 rerender

Invokes a rerendering of the branch.

Signature

rerender(type: "refresh" | "update"): void

Parameters

NameTypeOptionalDescription
type"refresh" | "update"NoSpecifies the rerender type. It can be one of the following values:
- refresh: Refresh the whole rendering (slower);
- update: Updates the rendering (faster).

🔧 reset

Resets the branch and removes all content in the branch.

Signature

reset(): void

🔧 swap

Swaps the branch with another branch.

Signature

swap(with: Branch): boolean

Parameters

NameTypeOptionalDescription
withBranchNoSpecifies the branch to swap with.

Return value

Returns true if the swap succeeded.