RuleEditor

The RuleEditor control enables users to input text using an “input group template”. You can either enter text manually or by using the intellisense menu. You can also customize the view for individual groups or within a group for specific group types.

Constructor

The Constructor supports one composite parameter. The following table describes its properties.

NameTypeDescription
connectIdStringMandatory parameter. It is the ID of the DOM element container for VariantsTree control. This element should exist in the DOM document. The VariantsTree DOM is placed as a child into the container. The default is ‘variantsTreeContainer’.
contextMenuEnabledBooleanOptional parameter. Turns context menu support on/off (widget creation, events tracking). The default is False.
isEditableBooleanOptional parameter. Turns text editing for the control on/off. The default is False.
templateObjectOptional composite parameter. It must include a ‘template’ array property containing the group names sequence and the parameters for each group from ‘template’ keyed with group names. Example: { template: [‘RuleConditionGroup’], templateGroups: { ‘RuleConditionGroup': { type: ‘grammar’, grammarFile: ‘RuleEditor/RuleGrammar.txt’, title: ‘Rule condition expression’, }, } }

Public Fields

NameTypeDescription
containerNodeDOM NodeA reference to the DOM Node used as a container for the control DOM.
domNodeDOM NodeA reference to the DOM Node that corresponds to the control.
contextMenuObject, MenuWidgetA reference to the menu widget used for the context menu.
intelliSenseMenuObject, MenuWidgetA reference to the menu widget used for the intellisense menu.

Public Methods

This section describes the public methods.

setInputTemplate

Use this method to create a new editor input template. The startNewInput method needs to be called before you can start working with the editor using this template method.

Input parameters

NameTypeDescription
inputTemplateObjectA template that contains a list of groups used as the ‘template’ array property as well as settings for each group.

getInputTemplate

Use this method to get the current editor input template.

Return value

Object. Template descriptor or null.

setEditState

Switch edit state for the control.

Input parameters

NameTypeDescription
isEditableBooleanThe applied value defines how the editor content can be modified.

isEditable

Get edit state of the control. It determines whether content is editable.

Return value Boolean

toggleCssClasses

This method enables toggling between DOM Node CSS classes. Input parameters

NameTypeDescription
cssClassNamesString | Array of StringsClass names that can be added or removed from the Node. You can pass several class names as a string parameter by separating them using the ‘space’ character.
turnStyleOnBooleanIf true, classes are added to the Node. If false, classes are removed.
targetNodeDOM Node, NullableNode that can be modified.

isInputValid

Determines if the values from all the input groups passed validation. Return value Boolean

isInputStarted

Determines if the template was set and all input groups were created. Return value Boolean

focus

Places focus into the active or first input group.

focusgroup

Places focus into a specific input group. Input parameters

NameTypeDescription
groupNameStringGroup name from template.

focusFirstEditableGroup

Places focus on the first input group, which supports user input.

undoChange

Undoes the previous editor value change.

redoChange

Re-does the change that was undone.

getCurrentState

Gets information about the current editor state. Return value Object with editor state information.

resetChanges

Resets all changes. The Editor returns to its initial values.

setStartState

Sets up the editor according to state settings. The current changes queue is dropped. Input parameters

NameTypeDescription
startStateObjectState information for editor settings restoration.

getValue

Gets the current editor value. Return value Object with values from all input groups. The key is the group name from the template.

getStringValue

Gets the editor value as string. Return value String. Concatenation of all input group values.

setValue

Sets the editor value. Input parameters

NameTypeDescription
inputDataObjectValue collection for editor input groups. Key = group name from template.

getErrorString

Gets value validation error as a string. Return value String. Concatenation of validation errors from all input groups.

isEditorFocused

Determines which editor control has focus. Return value Boolean

isMenuFocused

Determines which target menu control has focus. Input parameters

NameTypeDescription
targetMenuObject, MenuWidgetMenu widget used in the editor.

Return value Boolean

isValueModified

Identifies whether the initial editor value was modified. Return value Boolean

registerShortcut

Registers the shortcut for the editor. Input parameters

NameTypeDescription
keyCodeNumberButton key code.
isCtrlBooleanSpecifies whether the Ctrl key is pressed.
isShiftBooleanSpecifies whether the Shift key is pressed.
callbackHandlerFunctionMethod that is called when the shortcut is activated.

getGroupIndex

Gets the index for a particular input group. Input parameters

NameTypeDescription
targetGroupObject, InputGroupRegistered editor input group.

getGroupByIndex

Gets a particular input group by index. Input parameters

NameTypeDescription
groupIndexNumberGroup index from template.

Return value InputGroup

getGroupByDomNode

Gets input group using the related DOM Node. Input parameters

NameTypeDescription
targetDomNodeDOM NodeDOM Node belonging to the registered editor input group.

Return value InputGroup

getGroupName

Gets the name of a specific input group. Input parameters

NameTypeDescription
targetGroupObject, InputGroupRegistered editor input group.

Return value String. Group name from template.

getGroupByName

Gets registered editor input group by name from the template. Input parameters

NameTypeDescription
groupNameStringGroup name from active editor template.

Return value InputGroup

getGroupsCount

Counts the editor input groups. Return value Number

getNextGroup

Gets the next input group relative to the target group. If the target group is last, then the first group is returned. Input parameters

NameTypeDescription
targetGroupObject, InputGroupGroup relative to which next group is searched.

Return value InputGroup

getPrevGroup

Gets the previous input group relative to the target group. If the target group is last, then the first group is returned. Input parameters

NameTypeDescription
targetGroupObject, InputGroupGroup relatively to which previous group is searched.

Return value InputGroup

getGroupDomNode

Gets the previous input group relative to the target group. If target group is last, then the first group is returned. Input parameters

NameTypeDescription
targetGroupObject,InputGroup | StringExisting editor input group or it id.

Return value InputGroup

startNewInput

Creates editor input groups based on the current template. All previous input groups are removed.

showIntelliSense

Shows the intellisense menu for a particular input group. Input parameters

NameTypeDescription
targetGroupObject, InputGroupExisting editor input group.
allOptionsBooleanIf true, all available group values appear. If false, proposed values are limited based on the current group value.

hideIntelliSenseMenu

Hides active intellisense menu.

Events

Events described in this section are based on the Eventable core module. You can assign Handlers for these events using the addEventListener method.

onFocus

Event fires when the editor control has focus.

onBlur

Event fires when the focus moves away from the editor control.

onStateChanged

Event fires after group values are changed or the group loses focus.

onRender

Event fires after the editor creates DOM for input groups.

onValueChanged

Event fires after editor creates DOM for input groups.

onGroupValueEntered

Event fires if the group value changed and passed validation. Input parameters

NameTypeDescription
targetGroupObject, InputGroupAffected editor input group.
approvedValueStringApplied value, which passed validation.

Context Menu Events

The events described in this section belong to the dojo context menu widget. Use the dojo.connect and dojo.on modules to attach handlers for them.

onMenuInit

Event raised before context menu creation. Use it to create a list of required menu items. Input parameters

Name Type Description
menuEventEventCorresponding native context menu event.
targetGroupObject, InputGroupTarget editor input group that the context menu is created for.
targetGroupNameStringInput group name from template.

Return value Array of menu items descriptors.

onMenuItemClick

Event raised when the user clicks on the editor context menu item. Input parameters

NameTypeDescription
commandIdStringID of selected menu item.
contextDataAnyContext information for menu.

Return value
Array of menu items descriptors.